FrameworkElement.LayoutTransform FrameworkElement.LayoutTransform FrameworkElement.LayoutTransform FrameworkElement.LayoutTransform Property

定义

获取或设置在执行布局时应该应用于此元素的图形转换方式。Gets or sets a graphics transformation that should apply to this element when layout is performed.

public:
 property System::Windows::Media::Transform ^ LayoutTransform { System::Windows::Media::Transform ^ get(); void set(System::Windows::Media::Transform ^ value); };
public System.Windows.Media.Transform LayoutTransform { get; set; }
member this.LayoutTransform : System.Windows.Media.Transform with get, set
Public Property LayoutTransform As Transform

属性值

此元素应该使用的转换。The transform this element should use. 默认值为 IdentityThe default is Identity.

示例

下面的示例演示如何将应用LayoutTransform到元素。The following example shows how to apply a LayoutTransform to an element. 该示例创建一个实例Button , 并将其托管在父级Grid中。The example creates an instance of Button and hosts it within a parent Grid. 它还使用LayoutTransform属性将RotateTransform应用到ButtonIt also uses the LayoutTransform property to apply a RotateTransform to the Button.


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);


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);


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)


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

注解

RenderTransform不同的是LayoutTransform , 将影响布局的结果。In contrast to RenderTransform, LayoutTransform will affect results of layout.

设置转换可提供缩放和旋转的强大功能。Setting a transform provides powerful capabilities of scaling and rotating. 但会TranslateTransform忽略操作。 LayoutTransformHowever, LayoutTransform ignores TranslateTransform operations. 这是因为的子元素FrameworkElement的布局系统行为会自动校正到缩放元素位置和父元素的坐标系统中的任何偏移量。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.

LayoutTransform如果在不需要布局系统进行完全传递的方案中调用, 则可能导致应用程序性能不佳。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. 当你将应用LayoutTransform Children到的Panel集合时, 它会触发布局系统的新传递, 并强制对所有屏幕对象进行值和重新排列。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. 如果要更新完整的应用程序用户界面 (UI)user interface (UI), 此功能可能正是您所需要的。If you are updating the complete application 用户界面 (UI)user interface (UI), this functionality might be exactly what you need. 但是, 如果不需要完全布局处理过程, 请使用RenderTransform属性, 该属性不会调用布局系统, 因此通常是此方案的更好选择。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.

其中有用的LayoutTransform示例方案包括: 将元素 (如菜单组件) 从水平旋转到垂直, 反之亦然, 缩放元素 (放大) 焦点, 提供编辑行为, 等等。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.

依赖项属性信息Dependency Property Information

标识符字段Identifier field LayoutTransformProperty
元数据属性设置为trueMetadata properties set to true AffectsMeasure

适用于

另请参阅