Düzenle

Aracılığıyla paylaş


Visual.OnVisualParentChanged(DependencyObject) Method

Definition

Called when the parent of the visual object is changed.

protected public:
 virtual void OnVisualParentChanged(System::Windows::DependencyObject ^ oldParent);
protected internal virtual void OnVisualParentChanged (System.Windows.DependencyObject oldParent);
abstract member OnVisualParentChanged : System.Windows.DependencyObject -> unit
override this.OnVisualParentChanged : System.Windows.DependencyObject -> unit
Protected Friend Overridable Sub OnVisualParentChanged (oldParent As DependencyObject)

Parameters

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

Examples

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);
    }
}
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

Remarks

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.

Applies to

See also