RotateTransform use in WPF with VB.NET

In this article, We will see how to use RotateTransform in WPF with VB.NET.
  • 2685
RotateTransform is used for the process of rotating an element to a certain angle around a central point. We will use CenterX and CenterY properties in this control. We will use 30 degree in rotate button. The object around point values is (70,45).

Example:-
This code of .xaml:-

<Window x:Class="Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <Grid>
        <Button Name="RotatingButton" Grid.Row="0" Background="Yellow" FontSize="15"
Foreground="Red" Content="Rotate Transform"
                Width="125" Height="50" HorizontalAlignment="Center"
Click="RotatingButton_Click">
            <Button.RenderTransform>
                <RotateTransform x:Name="Trans_RotatingButton" Angle="0" CenterX="70"
CenterY="45" />
            </Button.RenderTransform>
        </Button>
    </Grid>
</
Window>

This code of .vb:-

Class Window1
    Private Sub RotatingButton_Click(ByVal sender As System.Object, ByVal e As
System.Windows.RoutedEventArgs)
        If Trans_RotatingButton.Angle = 360 Then
            Trans_RotatingButton.Angle = 0
        Else
            Trans_RotatingButton.Angle += 30
        End If
    End Sub
End Class

Output:-

RotateTransform1.bmp
 

We will click the Rotating Button after that change the angle of Rotating Button.
OR
We will click shift button + space button of keyword in the Rotating Button after that change the angle of Rotating Button.

RotateTransform2.bmp

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.