0

我正在将 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> 
4

4 回答 4

1

http://www.silverlight.net/content/samples/sl3/toolkitcontrolsamples/run/default.html

转到这个页面,有一个控件叫LayoutTransformer。请参阅该控件的示例。它处理图像、文本框、列表框等的旋转、缩放和倾斜。您将在那里获得代码。希望有帮助。!

于 2012-05-29T05:42:11.120 回答
0

You can try:

<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>
于 2012-05-29T06:50:13.613 回答
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>
于 2012-05-29T06:56:49.190 回答
0

假设您想缩小图像以适应原始图像空间,您可以使用我的CalculateConstraintScale方法从这里: Silverlight Rotate & Scale a bitmap image to fit in rectangle without cropping to scale the image based on the rotation.

单击此处查看为该答案创建的工作测试平台应用程序(如下图所示):

示例应用图像

于 2012-05-29T10:04:37.467 回答