如何翻转已经旋转到90度的textBlock?
旋转与翻转不同。希望您能帮助以下代码。
RotateTransform transform = new RotateTransform(); transform.Angle = 90.0; txtBlock.RenderTransform = transform; from here, I want to flip
答案 0 :(得分:0)
您可以使用ScaleTransform,例如:
var scaleTransform = new ScaleTransform() { ScaleX = -1 };
您可以根据需要使用ScaleY更改ScaleX以切换轴。
答案 1 :(得分:0)
如果您想要平滑的翻转动画,可以使用额外的ScaleTransform
,然后为此变换设置动画。
<Storyboard x:Key="Storyboard_Flip">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="front"
Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame KeyTime="00:00:00.2" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.2"
Storyboard.TargetName="back"
Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame KeyTime="00:00:00.4" Value="1" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
这是反向翻转动画。
<Storyboard x:Key="Storyboard_Reverse">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="back"
Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame KeyTime="00:00:00.2" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.2"
Storyboard.TargetName="front"
Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame KeyTime="00:00:00.4" Value="1" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
答案 2 :(得分:0)
如果你想要xaml中的东西,那就试试这个:
<TextBlock Height="45" HorizontalAlignment="Left" Margin="41,137,0,0" Name="textBlock1" Text="This is sample text" VerticalAlignment="Top" Width="296" RenderTransformOrigin="0.5,0.5" >
<TextBlock.RenderTransform>
<CompositeTransform ScaleX="-1"/>
</TextBlock.RenderTransform>
</TextBlock>
向y方向翻转需要您设置复合变换ScaleY="-1"