Step 3 of 3: Setting up Row Details

In this step you'll finish setting up the row details section of the grid. You'll add a RowDetailsTemplate to set the appearance of the details row, and you'll add code to set up the details row behavior.

To set up row details, complete the following steps:

1.   Add the following <c1:C1DataGrid.RowDetailsTemplate> between the <c1:C1DataGrid></c1:C1DataGrid> tags so that it appears similar to the following:

<c1:C1DataGrid x:Name="c1dg" CanUserAddRows="False" Margin="5">

    <c1:C1DataGrid.RowDetailsTemplate>

        <DataTemplate>

            <c1:C1DataGrid HeadersVisibility="Column" Margin="5" CanUserAddRows="False"/>

        </DataTemplate>

    </c1:C1DataGrid.RowDetailsTemplate>

</c1:C1DataGrid>

This template will customize the row details section display.

2.   Add LoadedRowDetailsPresenter="c1dg_LoadedRowDetailsPresenter" LoadingRow="c1dg_LoadingRow" to the <c1:C1DataGrid> tag so that it appears similar to the following:

<c1:C1DataGrid x:Name="c1dg" CanUserAddRows="False" LoadedRowDetailsPresenter="c1dg_LoadedRowDetailsPresenter" LoadingRow="c1dg_LoadingRow">

Later you'll add handlers for these events in code.

3.   In the Solution Explorer, right-click the project and select Add Reference. In the Add Reference dialog box, locate System.Xml.Linq and System.ComponentModel.DataAnnotations and click OK to add the reference.

4.   Right-click the page and select View Code in the context menu to open the Code Editor.

5.   In the Code Editor, import the following namespaces:

      C#

6.   Add code to the Page constructor to set the ItemsSource property:

      C#

7.   Add code for the c1dg_LoadedRowDetailsPresenter event to the MainPage class:

      C#

8.   Add code for the c1dg_LoadingRow event to the MainPage class to set the row details visibility for the first row:

      C#

 What You've Accomplished

If you save and run your application you'll observe that the grid is now populated with data from the products.xml file, and that the first row's details section is visible:

 

 

To collapse the row details section or expand another's row detail section, click the arrow icon in the row header of a row:

 

 

You've completed this tutorial and learned how to set up row details in the grid to display a master/detail grid view.


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