Zoom and PageChanged Events for FlowDocumentPageViewer
My app contains several screens that have content displayed in FlowDocuments, contained in the FlowDocumentPageViewer control. The problem that arose is that when the user changed the Zoom level on one screen, then navigated to another screen, the content on the new screen would be displayed at the default zoom level. And when navigating back to the original screen, the content would be reverted to the default zoom there too. My approach to solving this problem was to save the zoom level in a “preferences” class and set each viewers zoom to the saved value. However, a problem with this approach is that there was no way to know when the zoom level changed on the out-of-the-box FlowDocumentPageViewer control.
Some quick Bing-ing led me to an extended control downloadable from this page. The control overrides the FlowDocumentPageViewer’s OnIncreaseZoomCommand and OnDecreaseZoomCommand methods. This solution works great, but only when the user clicks the ‘+’ or ‘-‘ to control the FlowDocument’s zoom. The commands are not executed when the user uses the slider control to adjust the zoom, and no overridable methods or events are specific to the slider. So how can I know when the user uses the slider to adjust the zoom instead of the buttons?
For that, I had add another override to the extended control, this time OnPropertyChanged.
protected override void OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) { base.OnPropertyChanged(e); switch (e.Property.Name) { case "Zoom": OnZoomChanged(); break; } }
Comments