11-26-2009, 03:10 PM
It is quite easy to implement this behavior by yourself.
You need to disable MouseWheel handling on ZoomPanel and do it yourself from the code with ZoomAndTranslateToCenter method on the ZoomPanel.
The following is a sample of the implementation.
XAML:
Code:
The code simply translates the ZoomPanel to the current mouse position and than applies the zoom factor based on the mouse wheel movement.
Andrej Benedik
You need to disable MouseWheel handling on ZoomPanel and do it yourself from the code with ZoomAndTranslateToCenter method on the ZoomPanel.
The following is a sample of the implementation.
XAML:
Code:
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:zoomPanel="clr-namespace:Ab2d.Controls;assembly=Ab2d.Controls.ZoomPanel"
Title="Window1" Height="300" Width="300"
MouseWheel="Window_MouseWheel">
<Grid>
<zoomPanel:ZoomPanel Name="ZoomPanel1" IsMouseWheelZoomEnabled="False" ZoomMode="Move">
<TextBlock Text="12345"/>
</zoomPanel:ZoomPanel>
</Grid>
</Window>Code:
Code:
private void Window_MouseWheel(object sender, MouseWheelEventArgs e)
{
Point mousePosition;
double zoomFactor;
if (e.Delta > 0)
zoomFactor = 1.3;
else
zoomFactor = 1 / 1.3;
mousePosition = e.GetPosition(ZoomPanel1);
ZoomPanel1.ZoomAndTranslateToCenter(zoomFactor, mousePosition);
e.Handled = true;
}The code simply translates the ZoomPanel to the current mouse position and than applies the zoom factor based on the mouse wheel movement.
Andrej Benedik

