Items in the Control
ItemsControl
stores its content in an Items
property (of type ItemCollection
). Each item can be an arbitrary object (System.Object
) that by default gets rendered just as it would inside a content control. In other words, any UIElement
is rendered as expected, and (ignoring data templates) any other type is rendered as a TextBlock
containing the string returned by its ToString
method.
The simple ListBox
control shown in Chapter 2, “Child Elements and Keywords,” is an items control. Whereas Chapter 2 always adds ListBoxItem
s to the Items
collection, the following example adds arbitrary objects to Items
instead:
<ListBox xmlns:sys="using:System"> <Button>Button</Button> <x:Double>1.23</x:Double ...
Get XAML Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.