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.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft