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在內部呼叫, 而不需要連續InvalidateMeasure呼叫InvalidateArrange和。Calling 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您要針對不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.

經常呼叫InvalidateMeasureUpdateLayout特別會對效能造成明顯的影響。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.

適用於