In This Article

ZoomDecorator Class

Represents a decorator that can interactively zoom and pan it's child element.

public class ZoomDecorator : Decorator
Inheritance:
object Visual UIElement FrameworkElement Decorator object

Constructors

ZoomDecorator()

Initializes a new instance of the ZoomDecorator class.

public ZoomDecorator()

Properties

AnchorPoint

Gets the current anchor point of the view. This is a dependency property.

public Point AnchorPoint { get; }

Property Value

Point:

The current anchor point of the view. The default value is 0,0.

CenterPoint

Gets or sets the current center point of the view. This is a dependency property.

public Point? CenterPoint { get; set; }

Property Value

Point?:

The current center point of the view. The default value is null.

Child

Gets or sets the single child element of a Decorator.

public override UIElement Child { get; set; }

Property Value

UIElement

ChildSize

Gets the size of the child element. This is a dependency property.

public Size ChildSize { get; }

Property Value

Size:

The size of the child element. The default value is 0,0.

DefaultCenterPoint

Gets or sets the default center point of the view. This is a dependency property.

public Point? DefaultCenterPoint { get; set; }

Property Value

Point?:

The default center point of the view. The default value is null.

DefaultZoomLevel

Gets or sets the default zoom level. This is a dependency property.

public double DefaultZoomLevel { get; set; }

Property Value

double:

The default zoom level. The default value is 1.0.

HorizontalOffset

Gets or sets the current horizontal offset of the content. This is a dependency property.

public double HorizontalOffset { get; set; }

Property Value

double:

The current horizontal offset of the content. The default value is 0.0.

HorizontalScrollLineStep

Gets or sets the value used when incrementing and decrementing the horizontal offset by a line. This is a dependency property.

public Unit HorizontalScrollLineStep { get; set; }

Property Value

Unit:

The value used when incrementing and decrementing the horizontal offset by a line. The default value is 1 pixel.

HorizontalScrollPageStep

Gets or sets the value used when incrementing and decrementing the horizontal offset by a page. This is a dependency property.

public Unit HorizontalScrollPageStep { get; set; }

Property Value

Unit:

The value used when incrementing and decrementing the horizontal offset by a page. The default value is 100 percent of the viewport.

IsVirtualSpaceEnabled

Gets or sets a value indicating whether virtual space is enabled, which allows all parts of the content to be centered in the view. This is a dependency property.

public bool IsVirtualSpaceEnabled { get; set; }

Property Value

bool:

true if virtual space is enabled, which allows all parts of the content to be centered in the view; otherwise false. The default value is false.

MaxZoomLevel

Gets or sets a percentage value indicating the maximum zoom level of the content. This is a dependency property.

public double MaxZoomLevel { get; set; }

Property Value

double:

A percentage value indicating the maximum zoom level of the content. The default value is 10.0.

MinZoomLevel

Gets or sets a percentage value indicating the minimum zoom level of the content. This is a dependency property.

public double MinZoomLevel { get; set; }

Property Value

double:

A percentage value indicating the minimum zoom level of the content. The default value is 0.1.

PanAnimationDuration

Gets or sets the Duration to animate the panning from one location to another. This is a dependency property.

public Duration PanAnimationDuration { get; set; }

Property Value

Duration:

The Duration to animate the panning from one location to the next. The default value is 150ms.

Remarks

Set to 0ms or Duration.Automatic to disable pan animation.

See Also

VerticalOffset

Gets or sets the current vertical offset of the content. This is a dependency property.

public double VerticalOffset { get; set; }

Property Value

double:

The current vertical offset of the content. The default value is 0.0.

VerticalScrollLineStep

Gets or sets the value used when incrementing and decrementing the vertical offset by a line. This is a dependency property.

public Unit VerticalScrollLineStep { get; set; }

Property Value

Unit:

The value used when incrementing and decrementing the vertical offset by a line. The default value is 1 pixel.

VerticalScrollPageStep

Gets or sets the value used when incrementing and decrementing the vertical offset by a page. This is a dependency property.

public Unit VerticalScrollPageStep { get; set; }

Property Value

Unit:

The value used when incrementing and decrementing the vertical offset by a page. The default value is 100 percent of the viewport.

ViewportSize

Gets the size of the viewport. This is a dependency property.

public Size ViewportSize { get; }

Property Value

Size:

The size of the viewport. The default value is 0,0.

ZoomAnimationDuration

Gets or sets the Duration to animate the scale from one zoom level to the next. This is a dependency property.

public Duration ZoomAnimationDuration { get; set; }

Property Value

Duration:

The Duration to animate the scale from one zoom level to the next. The default value is 300ms.

Remarks

Set to 0ms or Duration.Automatic to disable zoom animation.

See Also

ZoomLevel

Gets or sets a percentage value indicating the current zoom level of the content. This is a dependency property.

public double ZoomLevel { get; set; }

Property Value

double:

A percentage value indicating the current zoom level of the content. The default value is double.NaN, which indicates that DefaultZoomLevel will be used.

ZoomLevelAnimated

Gets a percentage value indicating the current animated zoom level of the content.

public double ZoomLevelAnimated { get; }

Property Value

double:

A percentage value indicating the current animated zoom level of the content.

ZoomLevelStops

Gets or sets the possible zoom level stops when zooming in or out incrementally. This is a dependency property.

public DoubleCollection ZoomLevelStops { get; set; }

Property Value

DoubleCollection:

The possible zoom level stops when zooming in or out incrementally. The default value is null, which indicates that ZoomStep should be used.

ZoomStep

Gets or sets the value used when incrementing and decrementing the zoom level. This is a dependency property.

public double ZoomStep { get; set; }

Property Value

double:

The value used when incrementing and decrementing the zoom level. The default value is 0.1.

Methods

ArrangeOverride(Size)

When overridden in a derived class, positions child elements and determines a size for a FrameworkElement derived class.

protected override Size ArrangeOverride(Size finalSize)
Parameter Type Description
finalSize Size

The final area within the parent that this element should use to arrange itself and its children.

Returns

Size:

The actual size used.

BeginUpdate()

Flags that a bulk update is about to begin.

public void BeginUpdate()

CenterAndZoomInToPoint(Point?)

Centers the view to the specified point and zooms the content in using ZoomLevelStops or ZoomStep.

public void CenterAndZoomInToPoint(Point? point)
Parameter Type Description
point Point?

The point to center; otherwise null to use the current mouse position.

CenterAndZoomOutFromPoint(Point?)

Centers the view to the specified point and zooms the content out using ZoomLevelStops or ZoomStep.

public void CenterAndZoomOutFromPoint(Point? point)
Parameter Type Description
point Point?

The point to center; otherwise null to use the current mouse position.

CenterToPoint(Point?)

Centers the view to the specified point.

public void CenterToPoint(Point? point)
Parameter Type Description
point Point?

The point to center; otherwise null to use the current mouse position.

CenterView()

Centers the view.

public void CenterView()

CenterView(Orientation)

Centers the view.

public void CenterView(Orientation orientation)
Parameter Type Description
orientation Orientation

The orientation that should be centered.

EndUpdate()

Flags that a bulk update has ended.

public void EndUpdate()

EndUpdate(bool)

Flags that a bulk update has ended.

public void EndUpdate(bool animate)
Parameter Type Description
animate bool

if set to true then any changes can be animated.

LineDown()

Scrolls the content down by VerticalScrollLineStep.

public void LineDown()

LineDown(double)

Scrolls the content down by VerticalScrollLineStep multiplied by the specified factor.

public void LineDown(double factor)
Parameter Type Description
factor double

The factor to multiply the line step by.

LineLeft()

Scrolls the content left by HorizontalScrollLineStep.

public void LineLeft()

LineLeft(double)

Scrolls the content left by HorizontalScrollLineStep multiplied by the specified factor.

public void LineLeft(double factor)
Parameter Type Description
factor double

The factor to multiply the line step by.

LineRight()

Scrolls the content right by HorizontalScrollLineStep.

public void LineRight()

LineRight(double)

Scrolls the content right by HorizontalScrollLineStep multiplied by the specified factor.

public void LineRight(double factor)
Parameter Type Description
factor double

The factor to multiply the line step by.

LineUp()

Scrolls the content up by VerticalScrollLineStep.

public void LineUp()

LineUp(double)

Scrolls the content up by VerticalScrollLineStep multiplied by the specified factor.

public void LineUp(double factor)
Parameter Type Description
factor double

The factor to multiply the line step by.

MakeVisible(Visual, Rect)

Forces content to scroll until the coordinate space of a Visual object is visible.

public Rect MakeVisible(Visual visual, Rect rectangle)
Parameter Type Description
visual Visual

A Visual that becomes visible.

rectangle Rect

A bounding rectangle that identifies the coordinate space to make visible.

Returns

Rect:

A System.Windows.Rect that is visible.

MeasureOverride(Size)

When overridden in a derived class, measures the size in layout required for child elements and determines a size for the FrameworkElement-derived class.

protected override Size MeasureOverride(Size availableSize)
Parameter Type Description
availableSize Size

The available size that this element can give to child elements. Infinity can be specified as a value to indicate that the element will size to whatever content is available.

Returns

Size:

The size that this element determines it needs during layout, based on its calculations of child element sizes.

PageDown()

Scrolls the content down by VerticalScrollPageStep.

public void PageDown()

PageDown(double)

Scrolls the content down by VerticalScrollPageStep multiplied by the specified factor.

public void PageDown(double factor)
Parameter Type Description
factor double

The factor to multiply the page step by.

PageLeft()

Scrolls the content left by HorizontalScrollPageStep.

public void PageLeft()

PageLeft(double)

Scrolls the content left by HorizontalScrollPageStep multiplied by the specified factor.

public void PageLeft(double factor)
Parameter Type Description
factor double

The factor to multiply the page step by.

PageRight()

Scrolls the content right by HorizontalScrollPageStep.

public void PageRight()

PageRight(double)

Scrolls the content right by HorizontalScrollPageStep multiplied by the specified factor.

public void PageRight(double factor)
Parameter Type Description
factor double

The factor to multiply the page step by.

PageUp()

Scrolls the content up by VerticalScrollPageStep.

public void PageUp()

PageUp(double)

Scrolls the content up by VerticalScrollPageStep multiplied by the specified factor.

public void PageUp(double factor)
Parameter Type Description
factor double

The factor to multiply the page step by.

Pan(double, double)

Pans the view by the specified x and y offsets.

public void Pan(double xOffset, double yOffset)
Parameter Type Description
xOffset double

The offset to pan along the X-axis.

yOffset double

The offset to pan along the Y-axis.

ResetView()

Resets the view to the default zoom level and center point.

public void ResetView()

ZoomIn()

Zooms the content in using ZoomLevelStops or ZoomStep.

public void ZoomIn()

ZoomInToPoint(Point?)

Zooms the content in using ZoomLevelStops or ZoomStep with the specific point as an anchor.

public void ZoomInToPoint(Point? point)
Parameter Type Description
point Point?

The point to anchor; otherwise null to use the current mouse position.

ZoomOut()

Zooms the content out using ZoomLevelStops or ZoomStep.

public void ZoomOut()

ZoomOutFromPoint(Point?)

Zooms the content out using ZoomLevelStops or ZoomStep with the specific point as an anchor.

public void ZoomOutFromPoint(Point? point)
Parameter Type Description
point Point?

The point to anchor; otherwise null to use the current mouse position.

ZoomToFit()

Zooms the content so that it fits with-in the bounds of the control and centers the view.

public void ZoomToFit()

ZoomToFit(bool)

Zooms the content so that it fits with-in the bounds of the control.

public void ZoomToFit(bool centerView)
Parameter Type Description
centerView bool

if set to true the view will be centered.

ZoomToFit(Orientation)

Zooms the content so that it fits with-in the bounds of the control and centers the view.

public void ZoomToFit(Orientation orientation)
Parameter Type Description
orientation Orientation

The orientation that should be fitted.

ZoomToFit(Orientation, bool)

Zooms the content so that it fits with-in the bounds of the control.

public void ZoomToFit(Orientation orientation, bool centerView)
Parameter Type Description
orientation Orientation

The orientation that should be fitted.

centerView bool

if set to true the view will be centered.

Fields

AnchorPointProperty

Identifies the read-only AnchorPoint dependency property. This field is read-only.

public static readonly DependencyProperty AnchorPointProperty

CenterPointProperty

Identifies the CenterPoint dependency property. This field is read-only.

public static readonly DependencyProperty CenterPointProperty

ChildSizeProperty

Identifies the read-only ChildSize dependency property. This field is read-only.

public static readonly DependencyProperty ChildSizeProperty

DefaultCenterPointProperty

Identifies the DefaultCenterPoint dependency property. This field is read-only.

public static readonly DependencyProperty DefaultCenterPointProperty

DefaultZoomLevelProperty

Identifies the DefaultZoomLevel dependency property. This field is read-only.

public static readonly DependencyProperty DefaultZoomLevelProperty

HorizontalScrollLineStepProperty

Identifies the HorizontalScrollLineStep dependency property. This field is read-only.

public static readonly DependencyProperty HorizontalScrollLineStepProperty

HorizontalScrollPageStepProperty

Identifies the HorizontalScrollPageStep dependency property. This field is read-only.

public static readonly DependencyProperty HorizontalScrollPageStepProperty

IsVirtualSpaceEnabledProperty

Identifies the IsVirtualSpaceEnabled dependency property. This field is read-only.

public static readonly DependencyProperty IsVirtualSpaceEnabledProperty

MaxZoomLevelProperty

Identifies the MaxZoomLevel dependency property. This field is read-only.

public static readonly DependencyProperty MaxZoomLevelProperty

MinZoomLevelProperty

Identifies the MinZoomLevel dependency property. This field is read-only.

public static readonly DependencyProperty MinZoomLevelProperty

PanAnimationDurationProperty

Identifies the PanAnimationDuration dependency property. This field is read-only.

public static readonly DependencyProperty PanAnimationDurationProperty

VerticalScrollLineStepProperty

Identifies the VerticalScrollLineStep dependency property. This field is read-only.

public static readonly DependencyProperty VerticalScrollLineStepProperty

VerticalScrollPageStepProperty

Identifies the VerticalScrollPageStep dependency property. This field is read-only.

public static readonly DependencyProperty VerticalScrollPageStepProperty

ViewportSizeProperty

Identifies the read-only ViewportSize dependency property. This field is read-only.

public static readonly DependencyProperty ViewportSizeProperty

ZoomAnimationDurationProperty

Identifies the ZoomAnimationDuration dependency property. This field is read-only.

public static readonly DependencyProperty ZoomAnimationDurationProperty

ZoomLevelAnimatedProperty

Identifies the ZoomLevelAnimated dependency property. This field is read-only.

public static readonly DependencyProperty ZoomLevelAnimatedProperty

ZoomLevelProperty

Identifies the ZoomLevel dependency property. This field is read-only.

public static readonly DependencyProperty ZoomLevelProperty

ZoomLevelStopsProperty

Identifies the ZoomLevelStops dependency property. This field is read-only.

public static readonly DependencyProperty ZoomLevelStopsProperty

ZoomStepProperty

Identifies the ZoomStep dependency property. This field is read-only.

public static readonly DependencyProperty ZoomStepProperty