The following tutorial will walk you through the process of binding the C1DataGrid control to an RSS feed. Note that in this example, you will be binding the grid to the ComponentOne Buzz RSS news feed. Note that you can substitute another RSS feed in the steps below, if you choose.
Complete the following steps:
1. In Visual Studio, select File | New | Project.
2. In the New Project dialog box, select a language in the left pane and in the templates list select Silverlight Application. Enter a Name for your project, for example "C1DataGridRSS", and click OK. The New Silverlight Application dialog box will appear.
3. Click OK to accept the default settings, close the New Silverlight Application dialog box, and create your project.
4. In the Solution Explorer window, right-click the project name (for example, C1DataGridRSS) and select Add Reference.
5. In the Add Reference dialog box, locate the System.Xml.Linq library and click OK to add a reference to your project.
6. In the XAML window of the project, place the cursor between the <Grid> and </Grid> tags and click once.
7. Navigate to the Toolbox and double-click the C1DataGrid icon to add the grid control to MainPage.xaml. The XAML markup will now look similar to the following:
Note that the C1.Silverlight.DataGrid namespace and <c1:C1DataGrid></c1:C1DataGrid> tags have been added to the project.
8. If the <c1:C1DataGrid> tag includes existing content, delete it so it appears similar to the following:
9. Give your grid a name by adding x:Name="c1grid" to the <c1:C1DataGrid> tag so that it appears similar to the following:
By giving the control a unique identifier, you'll be able to access the C1DataGrid control in code.
10. Add AutoGenerateColumns="True" to the <c1:C1DataGrid> tag so that it appears similar to the following:
This way the grid will automatically generate and display data from the data source.
11. In the Solution Explorer, expand the MainPage.xaml node and double-click the MainPage.xaml.cs (or MainPage.xaml.vb) file to open it in the Code Editor.
12. Add the following import statement at the top of the file:
13. In the MainPage constructor, add an event handler and set up a WebClient object to read from the RSS feed with the following code:
Note that you can substitute another RSS feed for the ComponentOne Buzz feed, if you choose.
14. Add the News class:
15. Add the client_DownloadStringCompleted event handler:
16. Run your application and observe that the grid appears bound to the ComponentOne Buzz RSS news feed.
What You've Accomplished
Congratulations, you've completed this tutorial! In this topic you created a new Silverlight project, added a C1DataGrid control, and learned how to bind the grid to an RSS feed.