Data binding plays a major role for any technology. If you want me to rate the the learning experience of SL then surely Data Binding is going to be one of the prime destinations through the journey. Many articles and posts are available on this specific topic, but this series of articles try to introduce you to the concept with minimum content and with a real time sample.
In Data Driven application a lot revolves around the data source either in the form of a Database, XML or any other source. In my previous posts I think I was able to give a fair bit of introduction on how to create a data model using EnityFramework and RIA services. This post covers up to the displaying of the data in the UI.
Concept of Binding in Silverlight
To proceed further with this post I guess you may need to have some basic concept of what binding is. May be writing in detail about this concept will be repetitive so I suggest that you go through this article from MSDN which is a complete learning resource on the subject.
A Real World Scenario
Here I am going to explain a real application scenario of Master/Detail based
data, where the information regarding master will be shown to the detail.
Create a Silverlight Project with RIA service enabled and add Data Model using Entity Framework. The detailed steps are described in this earlier post. Here the "DataModel_SOI.edmx" Model container shows up the mapped properties to the scalar data fields.The "DomainService_SOI" service class will take care of server side querying.
Binding approach
Well the binding approach is quite straight forward, we will bind the the state
entity collection to the list box while loading of the page. Although the we
never intend to show the data in a State 1 Stae 2 … format, we will assign a
DisplayMember of the entity. The next step is to attach the selected List box
item to the Grid layout control which is above the Visual Tree of the controls
used for detailing. Once the selected state entity is attached to the Grid
Layout the properties can be used directly to the controls.
Of course the first step involved is to bind the state entities to the list box and the list should display the state name. The xaml code bellow shows the list box defined within the Grid layout control in Home page.
-
<ListBox Grid.Row="1″ HorizontalAlignment="Left" Margin="6,2,0,14″
-
Name="lstStates" Width="210″
-
FontFamily="Portable User Interface" FontSize="13″ FontWeight="Bold"
-
/>
I am going to bind the data to list box with following piece of code while Page Load.

salim salamPosted Sep 14, 2011, 2:03 AM
very nice one of the best
SapnaPosted Feb 6, 2011, 10:58 PM
Thanks for sharing your idea, keep doing it.
Manish TewatiaPosted Feb 6, 2011, 10:43 PM
Very nice article........
Mahesh ChandPosted Jan 18, 2011, 9:46 AM
Good start. Well explained with screens.
knightsPosted Jan 17, 2011, 12:56 PM
Manas, Its nice to have a precise example and foremost you mentioned a reference to MSDN article for further explanation which made this writeup as a sound one.Bring us back more stuff with the same spirit.Hi5
Dorababu MekaPosted Jan 17, 2011, 8:03 AM
Good one :)