Data-Binding to Controls

Silverlight 4 introduces the drag’n’drop data-binding, which works like the same technique in WPF. This is useful in WCF RIA Services applications, because it enables easily generating data-oriented web pages. At this point you need to add user controls for showing data within the desired page. In the Silverlight project, expand the Views folder and double-click the Home.xaml page. You could consider adding a dedicated page but for the sake of simplicity, an existing one can do the work the same. When the page is opened inside the Visual Studio designer, build the project and then open the Data Sources window by selecting the Data, Show Data Sources command. In the Data Sources window you find some business objects produced by the generation of the RIA Services application, including the Order entity. Drag this onto the DataGrid and when you release the mouse, you notice that Visual Studio 2010 has generated the following XAML code:

image

image

image

The DataGrid is now data-bound to a DomainDataSource control, which is the design-time representation of the domain service class, whereas the DomainDataSource.DomainContext property represents the data context for querying, loading, and submitting data. Notice how, similarly to what happens in Windows Presentation Foundation, the IDE generated DataGrid columns specific for the bound data type. At this point build the project. Further considerations on executing the application are discussed in the next subsection.

Datapager Control

Silverlight 4 introduces a DataPager control that you can use for paging data from RIA Services. This control is not covered here, so check out the MSDN documentation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.118.103