ZoomPanControl
A custom class that provides zoom and pan features for any FrameworkElement.
public class ZoomPanControl : ContentControl
Inherits from / implements: ContentControl
Remarks
The view is held in this class as three numbers - a scale and an X and Y offset, all in device-independent pixels of the control's own coordinate space - and the transform on the content follows them. It is deliberately not the other way round: reading the scale back off a running animation gives a value half way to somewhere, and two mouse-wheel notches in quick succession then compound the half-way value instead of the value the user asked for.
Members at a glance
ZoomPanControl | Creates a zoom and pan control. |
AutomaticZoomOutKey | Gets or sets the Key that will be enable automatic zooming out, when the user hits that specific Key. By default this key is Escape key. |
FitZoomLevel | Gets the scale at which the whole of the content fits inside the viewport, or 1 if the size of either is not yet known. |
IsAutomaticZoomingoutByKeypressEnabled | Gets or sets whether the user will be able to zoom out in full (if he is in zoomed in mode currently) by hitting a specified key (Escape key by default). |
IsInitialViewFitted | Gets or sets whether the control shows the whole of its content, scaled to fit the viewport, when it is first laid out and whenever its content is replaced. |
IsPanningEnabled | Gets or sets as to whether the control should support pan as well as zoom or just zoom. |
ZoomInKeyboardKey | Gets or sets the Keyboard key to perform "Zoom In" function. |
ZoomLevel | Gets or sets the scale currently applied to the content, where 1 is 1:1. |
ZoomMaximumDepth | Gets or sets the maximum zoom you would want the Zooming service to support. |
ZoomMinimumDepth | Gets or sets the minimum zoom you would want the Zooming service to support. |
ZoomOutKeyboardKey | Gets or sets the Keyboard key to perform "Zoom In" function. |
ZoomStep | Gets or sets the zoom factor for zooming the serviced target object - i.e. the Content. |
OnApplyTemplate | Called once the control template has been applied, which is where the named parts of the template first become reachable. |
OnContentChanged | Called when the content is replaced, so that the new content gets the transform and the opening view rather than inheriting the view the previous content was left in. |
ResetView | Returns the view to the state the control opens in - the fitted view, or 1:1 if IsInitialViewFitted is false . |
ZoomToFit | Scales the content so that all of it is visible, and centres it in the viewport. |
AutomaticZoomOutKeyProperty | Identifies the AutomaticZoomOutKey dependency property. |
IsAutomaticZoomingoutByKeypressEnabledProperty | Identifies the IsAutomaticZoomingoutByKeypressEnabled dependency property. |
IsInitialViewFittedProperty | Identifies the IsInitialViewFitted dependency property. |
IsPanningEnabledProperty | Identifies the IsPanningEnabled dependency property. |
ZoomInKeyboardKeyProperty | Identifies the ZoomInKeyboardKey dependency property. |
ZoomMaximumDepthProperty | Identifies the ZoomMaximumDepth dependency property. |
ZoomMinimumDepthProperty | Identifies the ZoomMinimumDepth dependency property. |
ZoomOutKeyboardKeyProperty | Identifies the ZoomOutKeyboardKey dependency property. |
ZoomStepProperty | Identifies the ZoomStep dependency property. |
Constructors
ZoomPanControl
Creates a zoom and pan control.
Properties
AutomaticZoomOutKey
Gets or sets the Key that will be enable automatic zooming out, when the user hits that specific Key. By default this key is Escape key.
FitZoomLevel
Gets the scale at which the whole of the content fits inside the viewport, or 1 if the size of either is not yet known.
ZoomToFit applies it. The control's own zoom-out key uses it too, so that the key and the button cannot disagree.IsAutomaticZoomingoutByKeypressEnabled
Gets or sets whether the user will be able to zoom out in full (if he is in zoomed in mode currently) by hitting a specified key (Escape key by default).
IsInitialViewFitted
Gets or sets whether the control shows the whole of its content, scaled to fit the viewport, when it is first laid out and whenever its content is replaced.
IsPanningEnabled
Gets or sets as to whether the control should support pan as well as zoom or just zoom.
ZoomInKeyboardKey
Gets or sets the Keyboard key to perform "Zoom In" function.
Up (Arrow Up) key.ZoomLevel
Gets or sets the scale currently applied to the content, where 1 is 1:1.
ZoomMinimumDepth and ZoomMaximumDepth.ZoomMaximumDepth
Gets or sets the maximum zoom you would want the Zooming service to support.
ZoomMinimumDepth
Gets or sets the minimum zoom you would want the Zooming service to support.
ZoomOutKeyboardKey
Gets or sets the Keyboard key to perform "Zoom In" function.
Down (Arrow Down) key.ZoomStep
Gets or sets the zoom factor for zooming the serviced target object - i.e. the Content.
Methods
OnApplyTemplate
Called once the control template has been applied, which is where the named parts of the template first become reachable.
OnContentChanged
Called when the content is replaced, so that the new content gets the transform and the opening view rather than inheriting the view the previous content was left in.
- oldContent
- The content being replaced.
- newContent
- The content replacing it.
ResetView
Returns the view to the state the control opens in - the fitted view, or 1:1 if IsInitialViewFitted is false .
ZoomToFit
Scales the content so that all of it is visible, and centres it in the viewport.
Fields
AutomaticZoomOutKeyProperty
Identifies the AutomaticZoomOutKey dependency property.
IsAutomaticZoomingoutByKeypressEnabledProperty
Identifies the IsAutomaticZoomingoutByKeypressEnabled dependency property.
IsInitialViewFittedProperty
Identifies the IsInitialViewFitted dependency property.
IsPanningEnabledProperty
Identifies the IsPanningEnabled dependency property.
ZoomInKeyboardKeyProperty
Identifies the ZoomInKeyboardKey dependency property.
ZoomMaximumDepthProperty
Identifies the ZoomMaximumDepth dependency property.
ZoomMinimumDepthProperty
Identifies the ZoomMinimumDepth dependency property.
ZoomOutKeyboardKeyProperty
Identifies the ZoomOutKeyboardKey dependency property.
ZoomStepProperty
Identifies the ZoomStep dependency property.