Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Zoom and ScrollViewer resize issue (Read 3554 times)
baba
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 16
Joined: Jan 20th, 2010
Zoom and ScrollViewer resize issue
Jun 7th, 2010 at 2:21pm
Print Post  
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
  
Back to top
 
IP Logged
 
baba
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 16
Joined: Jan 20th, 2010
Re: Zoom and ScrollViewer resize issue
Reply #1 - Jun 7th, 2010 at 3:08pm
Print Post  
Ok guys, nevermind... First of all the example does not reproduce the issue, second I think this behavior is by design when the ScroollViewer is, in turn, inside a stackPanel (this was my case).

My bad.

Cheers,
baba.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Zoom and ScrollViewer resize issue
Reply #2 - Jun 7th, 2010 at 3:12pm
Print Post  
Hi,

If you don't want it to resize, you might have to assign fixed Width and Height to the ScrollViewer, or to the respective column and row of the grid. Otherwise the ScrollViewer requests as much space as needed to fit the whole zoomed diagram during the layout pass, and it gets resized if the parent grid gives it more space than the initial size.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint