UIElement.InvalidateMeasure 方法

定義

使項目的測量狀態 (配置) 失效。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. 如果您要產生完整的版面配置實作為,以直接操作專案樹狀結構或類似的 advanced 案例,您應該只呼叫這個方法。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 不在 FreezableFrameworkElement 衍生類別上,但在變更時仍會影響版面配置的測量行程。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. 因此,請避免呼叫此方法,除非您在程式碼中對其他 Api 的後續呼叫絕對需要精確的版面配置狀態。Therefore, avoid calling this method unless you absolutely require precise layout state for subsequent calls to other APIs in your code.

適用於