UIElement.UpdateLayout Method

Definition

请确保此元素的所有可视子元素都正确地进行了布局更新。Ensures that all visual child elements of this element are properly updated for layout.

public:
 void UpdateLayout();
public void UpdateLayout ();
member this.UpdateLayout : unit -> unit
Public Sub UpdateLayout ()

Remarks

调用此方法时,falseIsArrangeValidfalse IsMeasureValid元素将调用强制执行布局更新的元素特定的 MeasureCoreArrangeCore 方法,并验证所有计算的大小。When you call this method, elements with IsMeasureValidfalse or IsArrangeValidfalse will call element-specific MeasureCore and ArrangeCore methods, which forces layout update, and all computed sizes will be validated.

如果布局没有变化,或者布局的排列和度量状态均无效,则调用此方法将不起作用。Calling this method has no effect if layout is unchanged, or if neither arrangement nor measurement state of a layout is invalid. 但是,如果布局在任何一个方面无效,则 UpdateLayout 调用将重做整个布局。However, if layout is invalid in either respect, the UpdateLayout call will redo the entire layout. 因此,应避免在元素树中的每次增量更改和次要更改之后调用 UpdateLayoutTherefore, you should avoid calling UpdateLayout after each incremental and minor change in the element tree. 布局系统将使用一种算法来以延迟方式执行元素布局,并使用一种算法来平衡性能和货币,并使用加权策略来将更改延迟到所有子元素有效。The layout system will perform element layout in a deferred manner, using an algorithm that balances performance and currency, and with a weighting strategy to defer changes to roots until all child elements are valid. 仅当你确实需要更新的大小和位置,并且仅在你确定控制的所有属性更改和可能影响布局的情况下,才调用 UpdateLayoutYou should only call UpdateLayout if you absolutely need updated sizes and positions, and only after you are certain that all changes to properties that you control and that may affect layout are completed.

Applies to

See also