Called when the parent of the visual object is changed.
Protected Friend Overridable Sub OnVisualParentChanged ( _ oldParent As DependencyObject _ )
Dim oldParent As DependencyObject Me.OnVisualParentChanged(oldParent)
protected internal virtual void OnVisualParentChanged( DependencyObject oldParent )
protected public: virtual void OnVisualParentChanged( DependencyObject^ oldParent )
protected internal function OnVisualParentChanged( oldParent : DependencyObject )
You cannot use methods in XAML.
A class that derives from Visual can choose to override this method.
There is no "VisualParentChanged" event provided that reports this change to instances. Therefore, you must override this method to handle notification scenarios and provide an instance version of the notification if that is part of your scenario.
The following example defines an overridden implementation of OnVisualParentChanged.
public class MyVisual : UIElement { // Class member definitions // ... protected override void OnVisualParentChanged(DependencyObject oldParent) { // Perform actions based on OnVisualParentChanged event. // ... // Call base class to perform standard event handling. base.OnVisualParentChanged(oldParent); } }
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003