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.

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

注解

此方法在内部调用 InvalidateArrangeThis 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. 只有高级方案才需要调用此方法。Calling this method is necessary only for advanced scenarios. 一个这样的高级方案是,如果您要为不在 FreezableFrameworkElement 派生类上的依赖属性创建 PropertyChangedCallback,而该属性在更改时仍会影响布局。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.

适用于

另请参阅