MSDN Library

VisualCollection Object

Represents a collection of UIElement objects.

Cannot be used in XAML
See Remarks.


This is the collection that underlies Canvas.Children. However, neither Canvas.Children nor VisualCollection can be used in XAML syntax. A VisualCollection is implicitly created by XAML parsing and are available if you examine the runtime object tree through scripting, but explicit uses in XAML are disallowed.

The general scripting usage is to make all scripting calls that adjust the VisualCollection inline with getting the Canvas.Children property, for instance myCanvas.Children.Add(content). However, you can also retain a variable for a VisualCollection if you wish; this will retain a reference that will remain synchronized with the actual collection and can be used to add to, remove from or otherwise examine the collection of child elements (it is not a one-time copy).

See Also


Community Additions

© 2015 Microsoft