Monday, December 27, 2010

Silverlight–Binding to a collection

Typically when you need to bind a value from a collection to a UIElement property you use the format: {Binding NameOfProperty}. (eg: <TextBlock Text=”{Binding FirstName}” />).

But what do you do when you need to bind to a collection of native types (eg: List<string>).

Simple – don’t enter the binding path. So the above textblock definition becomes: <TextBlock Text=”{Binding}” />

No comments: