本文為機器翻譯文章。如需檢視英文版,請選取 [原文] 核取方塊。您也可以將滑鼠指標移到文字上,即可在快顯視窗顯示英文原文。
譯文
原文

UIElement.Arrange 方法 (Rect)

 

放置子項目,並且判斷 UIElement 的大小。 父項目從 ArrangeCore 實作 (或 WPF 架構層級對等項目) 中呼叫此方法,以形成遞迴配置更新。 這個方法會構成配置更新的第二個階段。

命名空間:   System.Windows
組件:  PresentationCore (於 PresentationCore.dll)

public void Arrange(
	Rect finalRect
)

參數

finalRect
Type: System.Windows.Rect

父代為子項目計算的最終大小,提供作為 Rect 執行個體。

For WPF framework-level element deriving scenarios, behavior for M:System.Windows.UIElement.Arrange(System.Windows.Rect) should not (and cannot, unless you shadow) be changed. Instead, you should override the M:System.Windows.FrameworkElement.ArrangeOverride(System.Windows.Size) implementation in your class. Your M:System.Windows.FrameworkElement.ArrangeOverride(System.Windows.Size) implementation is called internally by M:System.Windows.UIElement.Arrange(System.Windows.Rect) as part of default WPF framework-level layout operations. Your M:System.Windows.UIElement.ArrangeCore(System.Windows.Rect) implementation should also call M:System.Windows.FrameworkElement.ArrangeOverride(System.Windows.Size) on each child element, if it has child elements.

For WPF core-level element deriving scenarios, the behavior for M:System.Windows.UIElement.Arrange(System.Windows.Rect) should not (and cannot, unless you shadow) be changed. Instead, you should override M:System.Windows.UIElement.ArrangeCore(System.Windows.Rect) in your class. Your M:System.Windows.UIElement.ArrangeCore(System.Windows.Rect) implementation is called internally by M:System.Windows.UIElement.Arrange(System.Windows.Rect) as part of default WPF framework-level layout operations. However, this assumes you are using WPF framework-level layout and its layout system, which is often not the case if you are specifically deriving elements at the WPF core-level from the T:System.Windows.UIElement base element class. Your M:System.Windows.UIElement.ArrangeCore(System.Windows.Rect) implementation should also call M:System.Windows.UIElement.Arrange(System.Windows.Rect) on each child element, if it has child elements. Note that the WPF core-level scenario implies that you are not using a T:System.Windows.FrameworkElement derived class, because T:System.Windows.FrameworkElement seals M:System.Windows.FrameworkElement.ArrangeCore(System.Windows.Rect).

Computation of WPF framework-level layout positioning in TLA#tla_winclient consists of a M:System.Windows.UIElement.Measure(System.Windows.Size) call and an M:System.Windows.UIElement.Arrange(System.Windows.Rect) call. During the M:System.Windows.UIElement.Measure(System.Windows.Size) call, the layout system determines an element's size requirements using a provided T:System.Windows.Size (availableSize) argument. During the M:System.Windows.UIElement.Arrange(System.Windows.Rect) call, the layout system finalizes the size and position of an element's bounding box. For more information, see Layout.

availableSize can be any number from zero to infinity. Elements to be laid out return the minimum Size they require through the availableSize parameter.

When a layout is first instantiated, it always receives a M:System.Windows.UIElement.Measure(System.Windows.Size) call before M:System.Windows.UIElement.Arrange(System.Windows.Rect). However, after the first layout pass, it may receive an M:System.Windows.UIElement.Arrange(System.Windows.Rect) call without a M:System.Windows.UIElement.Measure(System.Windows.Size); this can happen when a property that affects only M:System.Windows.UIElement.Arrange(System.Windows.Rect) is changed (such as alignment), or when the parent receives an M:System.Windows.UIElement.Arrange(System.Windows.Rect) without a M:System.Windows.UIElement.Measure(System.Windows.Size). A M:System.Windows.UIElement.Measure(System.Windows.Size) call will automatically invalidate an M:System.Windows.UIElement.Arrange(System.Windows.Rect) call.

Layout updates generally occur asynchronously (at a time determined by the layout system). An element might not immediately reflect changes to properties that affect element sizing (such as P:System.Windows.FrameworkElement.Width).

System_CAPS_note注意

Layout updates can be forced by using the M:System.Windows.UIElement.UpdateLayout method; however, calling this function is not recommended, as it is usually unnecessary and can cause poor performance. In many situations where calling M:System.Windows.UIElement.UpdateLayout might be appropriate, the layout system will probably already be processing updates. The layout system can process layout changes in a manner that can optimize all necessary updates as part of a package.

The layout system keeps two separate queues of invalid layouts, one for M:System.Windows.UIElement.Measure(System.Windows.Size) and one for M:System.Windows.UIElement.Arrange(System.Windows.Rect). The layout queue is sorted based upon the order of elements in the visual tree. Elements higher in the tree are at the top of the queue, in order to avoid redundant layouts caused by repeated changes in parents. Duplicate entries are automatically removed from the queue, and elements are automatically removed from the queue if they are already valid.

When updating layout, the M:System.Windows.UIElement.Measure(System.Windows.Size) queue is emptied first, followed by the M:System.Windows.UIElement.Arrange(System.Windows.Rect) queue. An element in the M:System.Windows.UIElement.Arrange(System.Windows.Rect) queue will never be arranged if there is an element in the M:System.Windows.UIElement.Measure(System.Windows.Size) queue.

.NET Framework
自 3.0 起供應
Silverlight
自 2.0 起供應
Windows Phone Silverlight
自 7.0 起供應
回到頁首
顯示: