AutomationPeer.InvalidatePeer 方法


触发对 AutomationPeer 主要属性的重新计算,如果属性已更改,则引发对自动化客户端的 PropertyChanged 通知。Triggers recalculation of the main properties of the AutomationPeer and raises the PropertyChanged notification to the Automation Client if the properties changed.

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


主属性的示例包括但不限于 LogicalChildrenBoundingRectangleExamples of main properties include, but are not limited to, LogicalChildren and BoundingRectangle.

通常,更新和通知在 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF)中的布局更新后自动发生。Typically, updates and notifications happen automatically after the update of the layout in Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF). (发生更新以响应 LayoutUpdated 的事件。)但有时,属性会发生更改,而不会引发 LayoutUpdated 事件。(The update occurs in response to the LayoutUpdated event.) Sometimes, however, properties change without raising the LayoutUpdated event. 例如,当整个 Window 移动时,不会引发 LayoutUpdated 事件。For example, when the whole Window moves, the LayoutUpdated event is not raised. 在此示例中,因为对象以屏幕坐标表示,所以 BoundingRectangle 对象集发生变化。In this example, the set of BoundingRectangle objects change because the objects are expressed in screen coordinates. 因此,Window 必须对 WindowAutomationPeer上的对等方调用 InvalidatePeerTherefore, the Window must call InvalidatePeer on its peer on WindowAutomationPeer.