Collection Items
XAML enables you to add items to the two main types of collections that support indexing: lists and dictionaries.
Lists
A list is any collection that implements the IList
interface or its generic counterpart. For example, the following XAML adds two items to a ListBox
control whose Items
property is an ItemCollection
that implements IList<object>
:
<ListBox xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <ListBox.Items> < ListBoxItem Content = "Item 1 "/> < ListBoxItem Content = "Item 2 "/> </ListBox.Items> </ListBox>
This is equivalent to the following C# code:
Windows.UI.Xaml.Controls.ListBox listbox = new Windows.UI.Xaml.Controls.ListBox ...
Get Universal Windows® Apps with XAML and C# 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.