UIElement.InvalidateMeasure UIElement.InvalidateMeasure UIElement.InvalidateMeasure UIElement.InvalidateMeasure Method

定义

使元素度量状态(布局)无效。Invalidates the measurement state (layout) for the element.

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

注解

调用此方法还会InvalidateArrange在内部调用, 无需连续调用InvalidateMeasureInvalidateArrangeCalling this method also calls InvalidateArrange internally, there is no need to call InvalidateMeasure and InvalidateArrange in succession. 在失效后, 元素将更新其布局, 这会以异步方式发生, 除非UpdateLayout调用来强制进行同步布局更改。After the invalidation, the element will have its layout updated, which will occur asynchronously, unless UpdateLayout is called to force a synchronous layout change.

WPF 框架级别布局系统自行处理元素的可视化树中的更改, 并且在大多数常见的布局失效情况下, 布局系统在必要时将调用与此方法等效的。The WPF framework-level layout system does its own handling of changes in the visual tree of an element, and in most common layout invalidation cases the layout system is calling the equivalent of this method when necessary. 仅当生成可直接操作元素树或类似高级方案的完整布局实现时, 才应调用此方法。You should only call this method if you are producing a complete layout implementation, which does direct manipulation of the element tree, or similar advanced scenarios. 一个这样的高级方案是, 如果您要PropertyChangedCallback为不Freezable在或FrameworkElement派生类上的依赖属性创建, 而该属性在更改时仍会影响布局的测量处理过程, 则为。One such advanced scenario is if you are creating a PropertyChangedCallback for a dependency property that is not on a Freezable or FrameworkElement derived class that still influences the measure pass of layout when it changes.

频繁调用InvalidateMeasure或特别是对UpdateLayout性能产生显著影响。Frequent calls to InvalidateMeasure or in particular to UpdateLayout have significant performance consequences. 因此, 请避免调用此方法, 除非你绝对需要精确布局状态才能对代码APIAPIs中的其他调用进行后续调用。Therefore, avoid calling this method unless you absolutely require precise layout state for subsequent calls to other APIAPIs in your code.

适用于