How UIElement.Rotation Property works

BitSmithy 2,041 Reputation points
2020-10-08T20:45:31.01+00:00

Hello,

I cant understand how
UIElement.Rotation Property works

In win docs:
https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.uielement.rotation?view=winrt-19041

is wrote that it sets rotation angle, but when i set this property in XAML uielement isn't rotated.
Below example doesnt work.

<Canvas xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" Width="500" Height="80" Rotation="40"><TextBlock Canvas.Left="24" Canvas.Top="5" Width="450" Text="2020" FontSize="45" FontFamily="Segoe UI" FontStyle="Normal" FontWeight="Normal" Foreground="#FF7FFFD4" Rotation="40"/></Canvas>

Universal Windows Platform (UWP)
0 comments No comments
{count} votes

Accepted answer
  1. Yan Gu - MSFT 2,676 Reputation points
    2020-10-09T03:02:39.61+00:00

    Hello,
    Welcome to Microsoft Q&A,

    Assigning value to UIElement.Rotation in the code can implement control rotation.

    Alternatively, you can also use UIElement.RenderTransform property and RotateTransform class in XAML to complete the rotation. For example,

    <TextBlock.RenderTransform>  
        <RotateTransform Angle="40" />  
    </TextBlock.RenderTransform>  
    

    Note, these two properties cannot be used at the same time.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.