This documentation is archived and is not being maintained.

Visual.OnVisualParentChanged Method

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
)

Parameters

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.
        base.OnVisualParentChanged(oldParent);
    }
}


.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: