UIElement.InvalidateVisual 方法


讓項目的呈現失效,並強制全新的配置傳遞。Invalidates the rendering of the element, and forces a complete new layout pass. 完成配置循環之後,會呼叫 OnRender(DrawingContext)OnRender(DrawingContext) is called after the layout cycle is completed.

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


這個方法會 InvalidateArrange 在內部呼叫。This method calls InvalidateArrange internally.

通常不會從您的應用程式程式碼呼叫此方法。This method is not generally called from your application code. WPF 架構層級配置系統會在專案的視覺化樹狀結構中自行處理變更,並且在必要時呼叫此方法的對等專案。The WPF framework-level layout system does its own handling of changes in the visual tree of an element, and would be calling the equivalent of this method when necessary already. 只有在 advanced 案例中才需要呼叫這個方法。Calling this method is necessary only for advanced scenarios. 其中一個這種 advanced 案例是針對相依性 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 layout when it changes.