我有一个图像控件位于网格控件内。我已经有一个按钮可以放大这张图片。放大后,会显示水平/垂直滚动条。然后我旋转包含网格的图像,图像和网格滚动条搞砸了。我应该如何将图像控件的放大和旋转结合起来?以下是我在项目中使用的代码。
我使用的图像控件放大代码(x是图像控件):
if ((x as Image) != null) { x.Height = x.Height * 1.3; x.Width = x.Width * 1.3; }
我使用的旋转代码(x 是图像控件):
if ((x as Image) != null)
{
RotateTransform rotate = new RotateTransform(); rotate.Angle = rotateAngle;
rotate.CenterX = x.Width / 2;
rotate.CenterY = x.Height / 2;
x.RenderTransform = rotate;
};
XAML 是:
<ScrollViewer x:Name="scrollViewer" Height="480" Width="615"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto">
<ScrollViewer.Content>
<Grid x:Name="ImageGrid">
<StackPanel x:Name="ImageStackPanel">
<Image Source="..." VerticalAlignment="Center" Width="220" Height="170" ></Image>
</StackPanel>
</Grid>
</ScrollViewer.Content>
</ScrollViewer>
有没有人可以借用任何现有的代码片段来解决这个技巧?