共用方式為


VisualCollection

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Represents a collection of UIElement objects.

Syntax Notes

See Remarks.

Managed Equivalent

UIElementCollection

Remarks

VisualCollection is the collection that underlies the Canvas.Children property. However, you cannot use either Canvas.Children or VisualCollection in XAML syntax. A VisualCollection is implicitly created by XAML parsing and is available if you examine the runtime object tree through scripting; however, 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 value (for example, myCanvas.Children.Add(content)). However, you can also retain a variable for a VisualCollection if you want; 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

Reference