0

How to flip a textBlock that already rotate to 90 degree?

Rotate is not same as flip. Hope you can help the following code.

RotateTransform transform = new RotateTransform();

 transform.Angle = 90.0;

txtBlock.RenderTransform = transform;   

from here, I want to flip

4

3 回答 3

0

You can probably use ScaleTransform, something like:

var scaleTransform = new ScaleTransform() { ScaleX = -1 };

You can change ScaleX with ScaleY to switch axes, depending on your needs.

于 2013-07-08T06:45:47.650 回答
0

You can use an additional ScaleTransform and then animate this transform if you want a smooth flipping animation.

      <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>

And here's the reverse flip animation.

      <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>
于 2013-07-08T06:51:23.530 回答
0

If you want something in xaml, then try this:

<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>

Flip in y direction needs you to set the composite transform ScaleY="-1"

于 2013-07-08T13:01:02.870 回答