Hi all,
I've wrapped a Diagram inside a ScrollViewer, here's the xaml:
<UserControl
xmlns="
http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="
http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:MindFusion.Diagramming.Silverlight;assembly=MindFusion.
Diagramming.Silverlight"
xmlns:controlsToolkit="clr-namespace:System.Windows.Controls;assembly=System.Wi
ndows.Controls.Toolkit"
xmlns:mc="
http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="DiagramAdapter"
Width="Auto" Height="Auto" >
<Grid x:Name="LayoutRoot"
Background="Transparent"
ShowGridLines="True"
Loaded="LayoutRoot_Loaded"
Width="Auto" Height="Auto"
>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0"/>
</ColumnDefinition>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="0"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0"/>
<RowDefinition Height="*"/>
<RowDefinition Height="0"/>
</Grid.RowDefinitions>
<ScrollViewer
Grid.Column="1" Grid.Row="1"
HorizontalScrollBarVisibility="Visible"
VerticalScrollBarVisibility="Visible">
<my:Diagram
x:Name="diagramControl"
Behavior="Custom"
AllowInplaceEdit="True"
DefaultShape="Rectangle"
BackBrush="AliceBlue"
LinkHeadShape="Triangle"
LinkCrossings="Arcs"
/>
</ScrollViewer>
</Grid>
</UserControl>
I also defined an event handle in code-behind in order to respond to mouse_wheel event and implement zooming in and out (I got the code from somewhere here or in examples):
double expectedZoom = diagramControl.ZoomFactor + (diagramControl.ZoomFactor) / (e.Delta / 12.0);
if ((expectedZoom >= 20) && (expectedZoom <= 180))
{
diagramControl.ZoomFactor += (diagramControl.ZoomFactor) / (e.Delta / 12.0);
}
The problems is that when I zoom in or out the scrollviewer gets resized as well, _sigh_.
Any idea?
Cheers,
baba