Binding to Indexed Properties

In addition to binding to nested properties, it's also possible to bind to indexed properties, with both integer and string indexes. The index selection syntax is much the same as it is in C#—simply append the index to the name of the property returning the collection surrounded by square brackets. For example, if a Person object had an Addresses property that returned a collection of Address objects, you could bind to the first Address object using the integer index syntax:

<TextBox DataContext="{StaticResource personResource}"          Text="{Binding Address[0].AddressLine1}" />

If the collection has string indexes, such as a Dictionary<string, string>, you can refer to the item using the string index syntax, ...

Get Pro Business Applications with Silverlight 5 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.