Silveright ScrollViewer with Image and ScaleTransform

对着背影说爱祢 提交于 2020-01-02 20:43:06

问题


I have the following xaml.

<ScrollViewer HorizontalAlignment="Stretch" Margin="107,0,0,0" Name="scrollViewer1" VerticalAlignment="Stretch" HorizontalScrollBarVisibility="Visible">
    <Image Name="image1" Stretch="None" MouseWheel="image1_MouseWheel" RenderTransformOrigin="0,0">
    </Image>
</ScrollViewer>

An the following code behind.

// initialise.
private TransformGroup group = new TransformGroup();
private ScaleTransform st = new ScaleTransform();
group.Children.Add(st);
image1.RenderTransform = group

// mouse event.
TransformGroup group = (TransformGroup)image1.RenderTransform;
ScaleTransform scale = (ScaleTransform)group.Children.Last();
double zoom = e.Delta > 0 ? .2 : -.2;
scale.ScaleX += zoom;
scale.ScaleY += zoom;

How do I get the scroller to take into account that the image is now a different size. The scroll bars remain the same size, and I cannot work out how to change them.

Thanks


回答1:


You need the LayoutTransformer from the Silverlight Toolkit. Instead of setting a RenderTransform on your Image, put it inside a LayoutTransformer.




回答2:


have you tried calling InvalidateScrollInfo on the scrollviewer?



来源:https://stackoverflow.com/questions/3921843/silveright-scrollviewer-with-image-and-scaletransform

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!