System.Windows.Media Namesp ...


.NET Framework Class Library
VisualCollection Class

Represents an ordered collection of Visual objects.

Namespace:  System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)
Syntax

Visual Basic (Declaration)
Public NotInheritable Class VisualCollection _
    Implements ICollection, IEnumerable
Visual Basic (Usage)
Dim instance As VisualCollection
C#
public sealed class VisualCollection : ICollection, 
    IEnumerable
Visual C++
public ref class VisualCollection sealed : ICollection, 
    IEnumerable
JScript
public final class VisualCollection implements ICollection, IEnumerable
XAML
You cannot directly create an instance of this class in XAML.
Remarks

A VisualCollection has implied context affinity. If a procedure attempts to access the VisualCollection from a different context than the context of the owning ContainerVisual, an exception is thrown.

Examples

The following example shows how to create a VisualCollection and add members to it.

C#
// Create a host visual derived from the FrameworkElement class.
// This class provides layout, event handling, and container support for
// the child visual objects.
public class MyVisualHost : FrameworkElement
{
    // Create a collection of child visual objects.
    private VisualCollection _children;

    public MyVisualHost()
    {
        _children = new VisualCollection(this);
        _children.Add(CreateDrawingVisualRectangle());
        _children.Add(CreateDrawingVisualText());
        _children.Add(CreateDrawingVisualEllipses());

        // Add the event handler for MouseLeftButtonUp.
        this.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(MyVisualHost_MouseLeftButtonUp);
    }
NoteNote:

For the complete sample, see Hit Test Using DrawingVisuals Sample.

Inheritance Hierarchy

System..::.Object
  System.Windows.Media..::.VisualCollection
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

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.
Version Information

.NET Framework

Supported in: 3.5, 3.0
See Also

Reference

Other Resources

Tags :


Page view tracker