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.

 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並將它裝載在父GridThe example creates an instance of Button and hosts it within a parent Grid. 它也會使用LayoutTransform屬性,將套用RotateTransformButtonIt 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);

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

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)

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


相對於RenderTransformLayoutTransform會影響版面配置的結果。In contrast to RenderTransform, LayoutTransform will affect results of layout.

設定轉換,可提供縮放和旋轉的強大的功能。Setting a transform provides powerful capabilities of scaling and rotating. 不過,LayoutTransform會忽略TranslateTransform作業。However, 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. 當您套用LayoutTransformChildren的集合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