O'Reilly logo

XAML Unleashed by Adam Nathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 System.Collections.IList, such as System.Collections.ArrayList or numerous collection classes defined by various frameworks. For example, the following XAML adds two items to a ListBox control whose Items property is an ItemCollection that implements IList:

<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 code:

C# (WPF and Silverlight):

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required