Assembly: PresentationFramework (in presentationframework.dll)
protected internal override function OnVisualParentChanged ( oldParent : DependencyObject )
The old parent element. May be a null reference (Nothing in Visual Basic) to indicate that the element did not have a visual parent previously.
The visual tree is potentially different than the logical tree, in that it omits elements that have no renderable visual, such as collections, and expands some elements on basis of their theme and style compositing. For more information, see Element Tree.Notes to Inheritors: The default implementation of this virtual method queries for the new parent, raises various initialization events, and sets internal flags about initialization state of the FrameworkElement as appropriate. Finally, it calls the successive base implementations as declared by UIElement, which in turn calls its base in Visual. Always call the base implementation to preserve this behavior, otherwise the element tree behavior for this element when declared as a child of another element may not be as expected. A few existing Windows Presentation Foundation (WPF) classes override this method, for instance: Window.OnVisualParentChanged, ListBoxItem.OnVisualParentChanged. The most common scenario is to enforce that the new parent be of a particular type. This might involve raising an exception if the new parent failed some manner of type test. A specialized version of this scenario exists in implementations for list items and menu items, which do not make any sense outside a parent visual that owns an appropriate collection to store them in. Note that these cases do not necessarily raise exceptions, because there might be designer scenarios that rely on reparenting elements that are momentarily without their "regular" parents). This method is also overridden in certain elements that are typically the root element, such as Window. Another case is elements that are the apparent root element in markup but which autogenerate a greater infrastructure in a compiled logical tree (such as Page). The Window and Page implementations deliberately seal the method.
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter EditionThe Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.