Visual.OnVisualParentChanged Method (DependencyObject)


Called when the parent of the visual object is changed.

Namespace:   System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)

protected internal virtual void OnVisualParentChanged(
	DependencyObject oldParent


Type: System.Windows.DependencyObject

A value of type DependencyObject that represents the previous parent of the Visual object. If the Visual object did not have a previous parent, the value of the parameter is null.

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.

.NET Framework
Available since 3.0
Return to top