#285 – Rotating an Image

You can rotate an Image control by assigning a rotation transform to its LayoutTransform property.

		<Image Source="TractorSm.png">
			<Image.LayoutTransform>
				<RotateTransform Angle="45"/>
			</Image.LayoutTransform>
		</Image>

Advertisement

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

2 Responses to #285 – Rotating an Image

  1. Jim says:

    How do you flip an image? I don’t want to rotate it 180 degrees, i just want to flip it so it looks like a reflection of the original. Example, I have a shaded button image with an arrow in it, so instead of it facing left, i’d like to use the same image and make it facing right. When i rotate it 180, it works but the shading is upside down and not the desired intent.

    • Sean says:

      Hi Jim,

      There’s a neat trick in XAML for flipping in image. You can just use a scale transform, with a negative value for the ScaleX or ScaleY properties.

      I can’t see to post XAML code in a comment, so I’ll do an example in tomorrow’s post on the blog.

      Thanks for asking!
      Sean

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: