Blog
How to rotate a Rectangle in WPF?
In this blog you can learn that how you can rotate a rectangle from its original position.rotation can be done in any direction.you can rotate a shape only by some controls and a little code.
Here we are discussing an example that how can you rotate a rectangle in WPF.for rectangle rotation you need canvas,rectangle and some rotation method.
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
<Canvas>
<Rectangle Canvas.Left="80" Canvas.Top="70" Width="70" Height="40" Fill="Silver" />
<Rectangle Canvas.Left="80" Canvas.Top="80" Width="70" Height="40" Fill="Black">
<Rectangle.RenderTransform>
<RotateTransform Angle="45" />
</Rectangle.RenderTransform>
</Rectangle>
</Canvas>
</Window> Main thing you need to define the rectangle coordinates and rotation angle.