Skip to content

Magnifier

XceedBoucherS edited this page Nov 4, 2019 · 7 revisions

Magnifier

Derives from Control

The Magnifier control does exactly what is sounds like. It allows a user to magnify parts of an application.

Usage

You can add the Magnifier to any element that is of type UIElement. This is done by using the MagnifierManager. You simply set the MagnifierManager.Magnifier property to the toolkit's Magnifier instance. The following snippet adds the Magnifier to the parent grid of a Window.

<Window x:Class="WPFToolkit.Extended.Samples.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        Title="MainWindow" Height="350" Width="525" >
    <Grid>
        <xctk:MagnifierManager.Magnifier>
            <xctk:Magnifier Radius="100" ZoomFactor=".4" />
        </xctk:MagnifierManager.Magnifier>
        <RichTextBox />
    </Grid>
</Window>

Now everything that is contained within the Grid will have the ability to be magnified.

Properties

You can control the appearance of the Magnifier by setting some of the available properties.

Name Description
FrameType Gets or sets the type of frame used by the Magnifier.
IsFrozen Gets if the Magnifier is frozen. When frozen, the magnifier will not update its position and will not follow the mouse position.
Radius Gets or sets the radius/size of the Magnifier.
Target Gets or sets the UIElement to which the Magnifier is attached.
ZoomFactor Gets or sets the amount to zoom into an element. The value ranges from 0.0 to 1.0. The smaller the number, the further zoomed in you are. 1.0 is normal text or 100% of original size, 0.0 is the most you can zoom in.

Methods

Method Description
Freeze Use this method with a true parameter to tell the Magnifier to stop updating its position (to not follow the mouse position). Use this method with a false parameter to tell the Magnifier to start updating its position(to follow the mouse position).

Example

The following code snippet attaches a Magnifier to a Window's parent Grid that has a Radius of 75, a red boder that is 1 pixel thick, and a ZoomFactor of 0.3526.

<Window x:Class="WPFToolkit.Extended.Samples.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        Title="MainWindow" Height="350" Width="525" >
    <Grid>
        <xctk:MagnifierManager.Magnifier>
            <xctk:Magnifier BorderBrush="Red"
                            BorderThickness="1"
                            Radius="75" 
                            ZoomFactor=".3526" />
        </xctk:MagnifierManager.Magnifier>
        <RichTextBox />
    </Grid>
</Window>

Support this project, check out the Plus Edition.

Clone this wiki locally