UIElement.OnVisualParentChanged(DependencyObject) 方法


在此 UIElement 的父元素报告其基础可视父元素发生更改时,调用此方法。Invoked when the parent element of this UIElement reports a change to its underlying visual parent.

protected public:
 override void OnVisualParentChanged(System::Windows::DependencyObject ^ oldParent);
protected internal override void OnVisualParentChanged (System.Windows.DependencyObject oldParent);
override this.OnVisualParentChanged : System.Windows.DependencyObject -> unit
Protected Friend Overrides Sub OnVisualParentChanged (oldParent As DependencyObject)



先前的父项。The previous parent. 如果 null 先前不具有父元素,则此项可以提供为 DependencyObjectThis may be provided as null if the DependencyObject did not have a parent element previously.


如果重写此方法,请始终调用基实现。If you override this method, always call the base implementation. 默认基实现对反向继承属性状态执行一些内部维护。The default base implementation performs some internal maintenance of reverse-inherited property state. 未能调用基实现将使此状态失效。Failing to call the base implementation will invalidate this state.

此方法重写 OnVisualParentChanged(DependencyObject)This method overrides OnVisualParentChanged(DependencyObject). FrameworkElementWindow 也会重写 OnVisualParentChanged(DependencyObject)UIElement 实现,并 Window 密封它。FrameworkElement and Window both also override the UIElement implementation of OnVisualParentChanged(DependencyObject), and Window seals it.