Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Visual Class
Visual Methods
 OnVisualParentChanged Method
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
Visual..::.OnVisualParentChanged Method

Called when the parent of the visual object is changed.

Namespace:  System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)
Visual Basic (Declaration)
Protected Friend Overridable Sub OnVisualParentChanged ( _
    oldParent As DependencyObject _
)
Visual Basic (Usage)
Dim oldParent As DependencyObject

Me.OnVisualParentChanged(oldParent)
C#
protected internal virtual void OnVisualParentChanged(
    DependencyObject oldParent
)
Visual C++
protected public:
virtual void OnVisualParentChanged(
    DependencyObject^ oldParent
)
JScript
protected internal function OnVisualParentChanged(
    oldParent : DependencyObject
)
XAML
You cannot use methods in XAML.

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 nullNothingnullptra null reference (Nothing in Visual Basic).

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.

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

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

.NET Framework

Supported in: 3.5, 3.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker