In This Article

Input Bindings

The ZoomContentControl supports interactive zooming and panning through the use of input bindings. This topic convers the default behavior, as well as how to customize the behavior.

Mouse Gestures

The Windows Presentation Framework (WPF) includes support for defining input bindings on controls, through the InputBindings collection. This collection defines various gestures, which when executed will raise an associated command.

There are two native WPF gestures that can be used: MouseGesture and KeyboardGesture. MouseGesture encompasses actions like clicking (and double-clicking) mouse buttons, while KeyboardGesture captures pressing keys. Both types support modifier keys, such as Control, Shift, etc. This tells the gesutre that the specifed modifier key must be pressed when the gesture is performed for the assocated command to be fired. For example, when using MouseAction.LeftClick with a modifier key of ModifierKeys.Control, then the associated command is only fired when the user click the left mouse button while holding down the control key.

The Shared Library adds an additional gesture that can bind mouse wheel actions to a command. MouseWheelGesture supports positive or negative changes (i.e. up or down scrolling of the mouse wheel), and can also be used with the ZoomContentControl.

There are several helper types that make defining a gesture easier via XAML, whic include KeyboardBinding, MouseBinding, and MouseWheelBinding. Using these classes, the Gesture property can be set to a simple string value. For example, setting the MouseBinding.Gesture property to "Control+LeftClick" will automatically create the appropriate MouseGesture.

Default Mouse Behavior

The ZoomContentControl includes several default input bindings that use MouseGesture and MouseWheelGesture with one of the commands defined by ZoomContentControlCommands.

The following table lists the default MouseGesture bindings and their associated command.

Gesture Command
LeftClick StartPanDrag
Control+LeftClick StartZoomIn
Control+Shift+LeftClick StartZoomOut
Shift+LeftClick StartPanDrag

The following table lists the default MouseWheelGesture bindings and their associated command.

Gesture Command
PositiveDelta LineUp
NegativeDelta LineDown
Shift+PositiveDelta LineLeft
Shift+NegativeDelta LineRight
Control+PositiveDelta ZoomInToPoint
Control+NegativeDelta ZoomOutFromPoint
Control+Shift+PositiveDelta ZoomInToPoint
Control+Shift+NegativeDelta ZoomOutFromPoint

The default input bindings can be disabled by setting AreDefaultInputBindingsEnabled to false. This allows the InputBindings to be completely customized from XAML.

Mouse Cursor

The ZoomContentControl will automatically update it's Cursor property based on the specified input bindings. Specifically, it looks for an input binding that uses a MouseGesture with a MouseAction.LeftClick action and specifies modifier keys that match the current key state. For example, if the Control key is currently pressed, then it will search for a MouseGesture with a MouseAction.LeftClick action and with ModifierKeys.Control defined.

If an input binding is found that matches the current state, then the cursor will be updated based on the specified command. The following table lists the commands and their associated cursor.

Command Cursor
CenterAndZoomInToPoint Screenshot
CenterAndZoomOutFromPoint Screenshot
CenterToPoint Screenshot
ResetView None
StartPanDrag Screenshot and Screenshot
StartZoomDrag Screenshot
StartZoomIn Screenshot
StartZoomOut Screenshot
StartZoomToRegion Screenshot
ZoomIn Screenshot
ZoomInToPoint Screenshot
ZoomOut Screenshot
ZoomOutFromPoint Screenshot
ZoomToFit None

The mouse cursor can be customized as needed by overriding the UpdateCursor method.