You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`ZoomContentControl` allows you to display content that can be zoomed in and out, as well as panned. It is especially useful for scenarios such as viewing large images, maps, or documents where users need control over zoom levels and panning.
|`CenterContent()`|`void`| Centers the content within the viewport. |
55
+
|`FitToCanvas()`|`void`| Adjusts the ZoomLevel so that the content fits within the viewport. |
56
+
|`ResetViewport()`|`void`| Resets the ZoomLevel to 1, and center the content. |
57
+
|`ResetZoom()`|`void`| Resets the ZoomLevel to 1. |
58
+
|`ResetScroll()`|`void`| Resets the scroll position to (0,0). |
69
59
70
60
### Usage
71
61
@@ -77,43 +67,17 @@ Below are the built-in interactions for ZoomContentControl usage. For these inte
77
67
78
68
#### Zooming (Ctrl + Mouse Wheel)
79
69
80
-
Ctrl + Mouse Wheel: Zoom in/out around the current cursor position.
70
+
Ctrl + Mouse Wheel: Zoom in/out around the current cursor position.
81
71
The `ScaleWheelRatio` property controls how quickly the zoom factor changes per mouse wheel tick.
82
72
83
73
#### Scrolling (Mouse Wheel)
84
74
85
-
Mouse Wheel by itself scrolls vertically.
86
-
Shift + Mouse Wheel scrolls horizontally.
75
+
Mouse Wheel by itself scrolls vertically.
76
+
Shift + Mouse Wheel scrolls horizontally.
87
77
The `PanWheelRatio` property determines how many pixels to move per mouse wheel tick.
88
78
89
79
#### Panning (Middle-Click + Drag)
90
80
91
-
Press and hold the middle button.
92
-
Drag to move the content.
81
+
Press and hold the middle button.
82
+
Drag to move the content.
93
83
Release the mouse button to stop panning.
94
-
95
-
#### Programmatic Control
96
-
97
-
Beyond user interactions, you can control zoom and pan directly:
98
-
99
-
`FitToCanvas()`: Automatically sizes the content so it fits the entire available space.
100
-
`ResetViewport()`: Resets both zoom level and offset to their defaults (zoom = 1, scroll offsets = 0).
101
-
102
-
### Advanced Usage: Overriding Pointer Methods
103
-
104
-
ZoomContentControl does not subscribe to pointer events directly. Instead, it overrides the base OnPointer methods. This lets you derive from ZoomContentControl and fully customize pointer handling in your subclass. For example:
105
-
106
-
```csharp
107
-
public classMyCustomZoomControl : ZoomContentControl
If you do not call `base.OnPointerPressed(e)`, you bypass the built-in pan/zoom logic entirely. This approach lets you disable or alter parts of the default pointer behavior without modifying the original code.
0 commit comments