This is a mirror of official site: http://jasper-net.blogspot.com/

Silverlight 4.0: Applying Data Templates on ListBox at Runtime

| Sunday, July 24, 2011
DataTemplates in Silverlight are typically used for visual representation of your data. They are particularly useful when you are binding an ItemsControl such as a ListBox to a collection. I was recently asked to make use of a DataTemplate on a ListBox at runtime, for performing Update operations.  In this article, I have demonstrated how to declare DataTemplates in XAML and to read and apply them at runtime.

Note: If you are interested in Silverlight development, make sure you check out this article - Microsoft Silverlight 4 Tutorials You Must Read

Step 1: Open VS2010 and create a new Silverlight application, name it as ‘SL4_Records_ListBox’. In the project, add a new class file and add the following classes in it:

silverlight-listbox-collection.png

The Employee class acts as an entity for Update Operation parameter. The EmployeeCollection class defines methods for reading all Employees and performing Update operations on the EmployeeCollection.

Step 2: Open MainPage.Xaml and define the following DataGrid and a ListBox. Define DataGrid columns bound with properties from the Employee class.

Read more: net curry com
QR: ShowArticle.aspx?ID=739

Posted via email from Jasper-net

0 comments: