Visual.OnVisualParentChanged Method

Called when the parent of the visual object is changed.

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

'Declaration
Protected Friend Overridable Sub OnVisualParentChanged ( _
	oldParent As DependencyObject _
)

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 Nothing.

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
		Inherits UIElement
		' Class member definitions
		' ...

		Protected Overrides Sub OnVisualParentChanged(ByVal oldParent As DependencyObject)
			' Perform actions based on OnVisualParentChanged event.
			' ...

			' Call base class to perform standard event handling.
			MyBase.OnVisualParentChanged(oldParent)
		End Sub
	End Class

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft