Step 1 of 3: Setting up the Localized Grid

In this step you'll create a Silverlight grid application using ComponentOne DataGrid for Silverlight. You'll create a new Silverlight project, add the C1DataGrid control to your application, and bind the grid.

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 "C1DataGridLocalization" in the Name text box, and click OK. The New Silverlight Application dialog box will appear.

3.   Click OK to close the New Silverlight Application dialog box and create your project.

4.   In the <UserControl> tag, replace Width="400" (or d:DesignWidth="400") with Width="450" to increase its size.

5.   In the XAML window of the project, place the cursor between the <Grid> and </Grid> tags and click once.

6.   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:

<UserControl xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml" x:Class="C1DataGridLocalization.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="450" Height="300">

    <Grid x:Name="LayoutRoot">

        <c1:C1DataGrid></c1:C1DataGrid>

    </Grid>

</UserControl>

7.   If the <c1:C1DataGrid> tag includes existing content, delete it so it appears similar to the following:

<c1:C1DataGrid></c1:C1DataGrid>

8.   Give your grid a name by adding x:Name="c1dg" to the <c1:C1DataGrid> tag so that it appears similar to the following:

<c1:C1DataGrid x:Name="c1dg">

By giving the control a unique identifier, you'll be able to access the C1DataGrid control in code.

9.   Add CanUserGroup="True" to the <c1:C1DataGrid> tag so that it appears similar to the following:

<c1:C1DataGrid x:Name="c1dg" CanUserGroup="True">

10.  In the Solution Explorer, right-click the C1DataGridLocalization project and select Build.

11.  In the Solution Explorer, right-click the MainPage.xaml file and click View Code in the context menu to open the Code Editor.

12.  Add the following code to the project to create the Data class:

      Visual Basic

      C#

13.  Add the following code to the MainPage constructor to populate the grid:

      Visual Basic

      C#

 What You've Accomplished

In this step you created a new Silverlight application, added a C1DataGrid control, and bound the control to a data source. In the next step, you'll add a resource file to localize the grid.


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