Databinding In Silverlight With New ItemContainerStyle
- 0 Comments
Recently on OzSilverlight mailing list a question was asked about data-bindings. The issue was how do you use data-binding once you have replaced ItemContainerStyle for a ListBox.
The answer is that you can replace the entire Template by giving it a new ControlTemplate and specify your bindings within the new template. I have created this example to illustrate this.
I have two list boxes. The top one uses the normal process of setting DataTemplate, the bottom one uses a totally new template. Note that I set the ItemContainerStyle to be a style I have defined at UserControl level. This is what my markup looks like:
In my C# code I create a books collection and assign it to ItemsSource property of both list boxes:
Below is the output when I run the project:
Silverlight comes packed some powerful data-binding concepts. As you saw in this example that I have complete control over what my control looks like and at the same time I can also use data-binding features available to me.
Technorati Tags: Silverlight, Databinding
