Step 2 of 3: Adding the C1DataGrid control

In the previous step you created a new Silverlight application with WCF RIA services enabled and added a new data source. In this step you'll set up your application and add the C1DataGrid control to the application. Complete the following steps:

1.   In the Solution Explorer, right click the C1DataGridRIA project and choose Add Reference. The Add Reference dialog box will appear.

2.   In the Add Reference dialog box, select the following assemblies and then click OK:

      System.Windows.Controls.Data

      System.Windows.Controls.DomainServices

      C1.Silverlight

      C1.Silverlight.DataGrid

      C1.Silverlight.DataGrid.Ria

This will add references to the project for the selected assemblies.

3.   In the Solution Explorer, double-click the MainPage.xaml file to open it.

4.   In the XAML window of the project, update the UserControl tag so it appears similar to the following:

      XAML

This markup will add references to the assemblies you added, and resize the UserControl.

5.   Add the following markup just after the Grid tag to create a row definition:

      XAML

This markup will set the layout of the page.

6.   Add the following markup within the Grid tag and just under the row definitions to create a C1RiaAdaptor:

      XAML

This markup will add the RIA data source.

7.   Add the following markup within the Grid tag and under the C1RiaAdaptor tag to add a header to the page:

      XAML

8.   Add the following markup within the Grid tag and under the Header to add a layout Grid to the page:

      XAML

You will add the C1DataGrid control within this layout grid.

9.   Add the following markup within within the content layout Grid you just added (just above the </Grid> tag) to add a standard DataPager control to the page:

      XAML

10.  Add the following markup within within the content layout Grid and just after the DataPager to add a C1DataGrid control to the page:

      XAML

This C1DataGrid control is bound to the database added earlier and includes defined and bound columns.

11.  Add the following markup within within the content layout Grid and just after the C1DataGrid to add a text box and two buttons to the page:

      XAML

At run time, the text box will display the location of any changes made to the grid and the buttons will allow you to reject or apply any changes made to the grid at run time. In the next step you'll add code to implement the XAML you added to the application.

12.  Right-click the MainPage.xaml page and choose View Code to open the MainPage.xaml.cs (or MainPage.xaml.vb) page in the Code Editor.

13.  Add the imports statement to the top of the page:

      Visual Basic

      C#

14.  Add the following code within the MainPage class to implement the controls that were added in XAML:

      Visual Basic

      C#

 What You've Accomplished

You learned how to bind the C1DataGrid control to an RIA Services data source. You created a Silverlight application, added the data source, and added and implemented the C1DataGrid control. In the next step you'll run the application, to view its run time interactions.


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.