Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
 LayoutTransform 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
FrameworkElement..::.LayoutTransform Property

Gets or sets a graphics transformation that should apply to this element when layout is performed. This is a dependency property.

Namespace:  System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)
Visual Basic (Declaration)
Public Property LayoutTransform As Transform
Visual Basic (Usage)
Dim instance As FrameworkElement
Dim value As Transform

value = instance.LayoutTransform

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

Property Value

Type: System.Windows.Media..::.Transform
The transform this element should use. The default is Identity.

Identifier field

LayoutTransformProperty

Metadata properties set to true

AffectsMeasure

In contrast to RenderTransform, LayoutTransform will affect results of layout.

Setting a transform provides powerful capabilities of scaling and rotating. However, LayoutTransform ignores TranslateTransform operations. This is because the layout system behavior for child elements of a FrameworkElement auto-corrects any offsets to the position of a scaled or rotated element into the layout and coordinate system of the parent element.

Example scenarios where LayoutTransform would be useful include: rotating elements such as menu components from horizontal to vertical or vice versa, scaling elements (zooming in) on focus, providing editing behavior, etc.

This example shows how to apply a LayoutTransform to an element. The example creates an instance of Button and hosts it within a parent Grid. It also uses the LayoutTransform property to apply a RotateTransform to the Button.

Performance Note: Before using LayoutTransform, be sure that you understand how this property can affect performance.

LayoutTransform can lead to poor application performance if you invoke it in a scenario that does not require a full pass by the layout system. When you apply a LayoutTransform to the Children collection of the Panel, it triggers a new pass by the layout system and forces all on-screen objects to be remeasured and rearranged. If you are updating the complete application user interface (UI), this functionality might be exactly what you need. However, if you do not need a full layout pass, use the RenderTransform property, which does not invoke the layout system, and therefore, is typically a better choice for this scenario.

Visual Basic
Dim btn2 As New Button()
btn2.Background = Brushes.LightCoral
btn2.Content = "RotateTransform"
btn2.LayoutTransform = New RotateTransform(45, 25, 25)
Grid.SetRow(btn2, 0)
Grid.SetColumn(btn2, 1)
grid1.Children.Add(btn2)

C#
Button btn2 = new Button();
btn2.Background = Brushes.LightCoral;
btn2.Content = "RotateTransform";
btn2.LayoutTransform = new RotateTransform(45, 25, 25);
Grid.SetRow(btn2, 0);
Grid.SetColumn(btn2, 1);
grid1.Children.Add(btn2);

Visual C++
Button^ btn2 = gcnew Button();
btn2->Background = Brushes::LightCoral;
btn2->Content = "RotateTransform";
btn2->LayoutTransform = gcnew RotateTransform(45, 25, 25);
Grid::SetRow(btn2, 0);
Grid::SetColumn(btn2, 1);
grid1->Children->Add(btn2);

XAML
<Button Grid.Row="0" Grid.Column="1" Background="LightCoral" Content="RotateTransform Applied">
  <Button.LayoutTransform>
    <RotateTransform CenterX="25" CenterY="25" Angle="45" />
  </Button.LayoutTransform>
</Button>

For the complete sample, which shows each of the available layout transforms, see Applying a LayoutTransform to an Element Sample.

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
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker