Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
UIElement Class
 RenderTransform Property
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
UIElement..::.RenderTransform Property

Gets or sets transform information that affects the rendering position of this element. This is a dependency property.

Namespace:  System.Windows
Assembly:  PresentationCore (in PresentationCore.dll)
Visual Basic (Declaration)
Public Property RenderTransform As Transform
Visual Basic (Usage)
Dim instance As UIElement
Dim value As Transform

value = instance.RenderTransform

instance.RenderTransform = value
C#
public Transform RenderTransform { get; set; }
Visual C++
public:
property Transform^ RenderTransform {
    Transform^ get ();
    void set (Transform^ value);
}
JScript
public function get RenderTransform () : Transform
public function set RenderTransform (value : Transform)
XAML
For XAML information, see the Transform type.

Property Value

Type: System.Windows.Media..::.Transform
Describes the specifics of the desired render transform. The default is Transform..::.Identity.

Identifier field

RenderTransformProperty

Metadata properties set to true

None

A render transform does not regenerate layout size or render size information. Render transforms are typically intended for animating or applying a temporary effect to an element. For example, the element might zoom when focused or moused over, or might jitter on load to draw the eye to that part of the user interface (UI).

This example shows how to use a ScaleTransform to flip a UIElement horizontally or vertically. In this example, a Button control (a type of UIElement) is flipped by applying a ScaleTransform to its RenderTransform property.

The following illustration shows the button to flip.

The UIElement to flip

A button with no transform

The following shows the code that creates the button.

XAML
<Button Content="Flip me!" Padding="5">
</Button>

To flip the button horizontally, create a ScaleTransform and set its ScaleX property to -1. Apply the ScaleTransform to the button's RenderTransform property.

XAML
<Button Content="Flip me!" Padding="5">
  <Button.RenderTransform>
    <ScaleTransform ScaleX="-1" />
  </Button.RenderTransform>
</Button>
The button after applying the ScaleTransform

A button flipped horizontally about (0,0)

As you can see from the previous illustration, the button was flipped, but it was also moved. That's because the button was flipped from its top left corner. To flip the button in place, you want to apply the ScaleTransform to its center, not its corner. An easy way to apply the ScaleTransform to the buttons center is to set the button's RenderTransformOrigin property to 0.5, 0.5.

XAML
<Button Content="Flip me!" Padding="5"
  RenderTransformOrigin="0.5,0.5">
  <Button.RenderTransform>
    <ScaleTransform ScaleX="-1" />
  </Button.RenderTransform>
</Button>
The button with a RenderTransformOrigin of 0.5, 0.5

A button flipped horizontally about its center

To flip the button vertically, set the ScaleTransform object's ScaleY property instead of its ScaleX property.

XAML
<Button Content="Flip me!" Padding="5"
  RenderTransformOrigin="0.5,0.5">
  <Button.RenderTransform>
    <ScaleTransform ScaleY="-1" />
  </Button.RenderTransform>
</Button>
The vertically flipped button

A button flipped vertically about its center

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
LayoutTransform as an alternate to RenderTransform      KitWest   |   Edit   |   Show History

I had to use LayoutTransform to rotate text before placing it into a tall, narrow button:

    <Button Height="148" Width="25">
<TextBlock x:Name="MyButtonTextBlock" Text="Rotated button text" >
<TextBlock.LayoutTransform>
<RotateTransform Angle="90"/>
</TextBlock.LayoutTransform>
</TextBlock>
</Button>
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker