C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
How to rotate a Rectangle in WPF?
WhatsApp
Shalini Juneja
14y
21
k
0
0
25
Blog
RotateRectangle.zip
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.
People also reading
Membership not found