我正在将XAML绑定到RotateAngle
属性,并且它与一个“但是”很有效。图像显示裁剪。旋转后,图像控制似乎没有刷新/调整大小。有没有办法强制调整图像和滚动查看器的大小?
<ScrollViewer Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" VerticalScrollBarVisibility="Auto" BorderThickness="0" HorizontalScrollBarVisibility="Auto">
<Image
VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
Source="{Binding Input, Converter={StaticResource ByteArrayToBitmapConverter}}"
RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<RotateTransform Angle="{Binding RotateAngle}"></RotateTransform>
</Image.RenderTransform>
</Image>
</ScrollViewer>
答案 0 :(得分:1)
http://www.silverlight.net/content/samples/sl3/toolkitcontrolsamples/run/default.html
转到此页面,有一个名为LayoutTransformer的控件。请参阅该控件的示例。它处理图像,文本框,列表框等的旋转,缩放和倾斜。 你会得到那里的代码。 希望有所帮助。!
答案 1 :(得分:0)
您可以尝试:
<Image x:name="ctrl"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
Source="{Binding Input, Converter={StaticResource ByteArrayToBitmapConverter}}"
RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<RotateTransform Angle="{Binding DataContext.RotateAngle, ElementName=ctrl}"></RotateTransform>
</Image.RenderTransform>
</Image>
答案 2 :(得分:0)
或者您可以使用:
<Image
VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
Source="{Binding Input, Converter={StaticResource ByteArrayToBitmapConverter}}"
RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<RotateTransform Angle="{Binding DataContext.RotateAngle, RelativeSource={RelativeSource Self}}"></RotateTransform>
</Image.RenderTransform>
</Image>
答案 3 :(得分:0)
假设您要缩小图像以适合原始图像空间,可以使用我的CalculateConstraintScale
方法:
Silverlight Rotate & Scale a bitmap image to fit within rectangle without cropping根据轮换缩小图像。
Click here for a working testbed app created for that answer(如下图所示):