TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
How to rotate images in Silverlight
Praveen Kumar
Sep 04 2009
Resource
0
0
30.7
k
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
Rotating images in Silverlight is very simple.
From XAML:
<
UserControl
xmlns
=
http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns
:
x
=
http://schemas.microsoft.com/winfx/2006/xaml
x
:
Class
="imginSL.MainPage"
Width
="640"
Height
="480">
<
Grid
x
:
Name
="LayoutRoot"
Background
="White">
<
Image
x
:
Name
="img"
Margin
="151,127,208,142"
Source
="Waterfall.jpg"
Stretch
="Fill">
<
Image.RenderTransform
>
<
RotateTransform
Angle
="45"
CenterX
="100"
CenterY
="100"></
RotateTransform
>
</
Image.RenderTransform
>
</
Image
>
</
Grid
>
</
UserControl
>
Same can be achieved from code behind. The sample code is given below:
C# Code:
RotateTransform
rotate =
new
RotateTransform
();
rotate.Angle = 45;
rotate.CenterX = img.Width / 2;
rotate.CenterY = img.Height / 2;
img.RenderTransform = rotate;
Output:
silverlight