偏移量上的WPF旋转变换问题
在以下方面:偏移量上的WPF旋转变换问题,wpf,rotatetransform,Wpf,Rotatetransform,在以下方面: <Rectangle Height="60" HorizontalAlignment="Left" Margin="50,100,0,0" Name="rectangle2" Stroke="Black" VerticalAlignment="Top" Width="60" > <Rectangle.RenderTransform> <TransformGroup> <RotateTransform Angle="4
<Rectangle Height="60" HorizontalAlignment="Left" Margin="50,100,0,0" Name="rectangle2" Stroke="Black" VerticalAlignment="Top" Width="60" >
<Rectangle.RenderTransform>
<TransformGroup>
<RotateTransform Angle="45" CenterX="30" CenterY="30"/>
</TransformGroup>
</Rectangle.RenderTransform>
要在其中心旋转矩形,我必须将中心X和Y设置为矩形大小的一半。在标记中有这样做的方法吗
类似CenterX=“{Binding Path=Width\2}”的内容 您可以在
矩形
本身上设置RenderTrasformOrigin
属性:
<Rectangle Height="60" HorizontalAlignment="Left" Margin="50,100,0,0" Name="rectangle2"
Stroke="Black" VerticalAlignment="Top" Width="60"
RenderTrasformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<TransformGroup>
<RotateTransform Angle="45" />
</TransformGroup>
</Rectangle.RenderTransform>
非常好。我知道这将是直截了当的。