Visual.AddVisualChild Method
Defines the parent-child relationship between two visuals.
Assembly: PresentationCore (in PresentationCore.dll)
Parameters
- child
- Type: System.Windows.Media.Visual
The child visual object to add to parent visual.
The AddVisualChild method sets up the parent-child relationship between two visual objects. This method must be used when you need greater low-level control over the underlying storage implementation of visual child objects. VisualCollection can be used as a default implementation for storing child objects.
The following example shows how to define custom storage requirements for a visual child. The example uses the AddVisualChild and RemoveVisualChild methods to sets up the parent-child relationship between the parent visual and child. In order for the visual tree to be enumerated correctly, the example provides overridden implementations of the GetVisualChild method and VisualChildrenCount property.
Note |
|---|
Although it is possible to use VisualCollection to create parent-child relationships between visual objects, it is more efficient to provide your own custom storage implementation when only one child is linked to a parent. |
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note