VisualCollection::Add Method (Visual^)
Appends a Visual to the end of the VisualCollection.
Assembly: PresentationCore (in PresentationCore.dll)
Parameters
- visual
-
Type:
System.Windows.Media::Visual^
The Visual to append to the VisualCollection.
| Exception | Condition |
|---|---|
| ArgumentException | An ArgumentException is thrown if the Visual is a root element. |
Adding a Visual whose value is null is permitted and does not raise an exception.
The Add method also sets up the parent-child relationship between the parent visual, which is the owner of the VisualCollection, and the child visual.
If you need greater low-level control over the underlying storage implementation of visual child objects of a custom class, consider using the AddVisualChild and RemoveVisualChild methods. When you use these methods, you must define your own storage implementation, and do not use VisualCollection.
The following example shows how to create a VisualCollection and add members to it.
Note |
|---|
For the complete sample, see Hit Test Using DrawingVisuals Sample. |
Available since 3.0
