Export (0) Print
Expand All

DataGrid.RowDetailsTemplate Property

Gets or sets the template that is used to display the content of the details section of rows.

Namespace:  System.Windows.Controls
Assembly:  System.Windows.Controls.Data (in System.Windows.Controls.Data.dll)

public DataTemplate RowDetailsTemplate { get; set; }
<sdk:DataGrid>
  <sdk:DataGrid.RowDetailsTemplate>
    dataTemplate
  </sdk:DataGrid.RowDetailsTemplate>
</sdk:DataGrid>
<sdk:DataGrid RowDetailsTemplate="templateReference"/>

XAML Values

dataTemplate

A DataTemplate object element that defines the display for this data grid's rows. For more information, see DataGrid Styles and Templates.

templateReference

A StaticResource reference to an existing DataTemplate definition.

Property Value

Type: System.Windows.DataTemplate
The template that is used to display row details. The default is null.

Dependency property identifier field: RowDetailsTemplateProperty

In the XAML usage, both attribute and property element syntax for RowDetailsTemplate are shown. Defining the template inline as opposed to referencing an existing one as a resource are both equally valid scenarios.

The following code example demonstrates how to set the RowDetailsTemplate property. This example is part of a larger example available in the DataGrid class overview.


<sdk:DataGrid x:Name="dataGrid3" 
    Height="140" Margin="0,5,0,10"
    RowDetailsVisibilityMode="VisibleWhenSelected" >            
    <sdk:DataGrid.RowDetailsTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <TextBlock FontSize="12" Text="Address: " />
                <TextBlock FontSize="12" Text="{Binding Address}"/>
            </StackPanel>
        </DataTemplate>
    </sdk:DataGrid.RowDetailsTemplate>                
</sdk:DataGrid>


The following code example demonstrates how to set the RowDetailsTemplate property in code. This example is part of a larger example available in the How to: Display and Configure Row Details in the DataGrid Control topic.


<sdk:DataGrid x:Name="dataGrid1" Height="400" IsReadOnly="True" >
    <sdk:DataGrid.RowDetailsTemplate>
        <!-- Begin row details section. -->
        <DataTemplate>
            <Border BorderBrush="Black" BorderThickness="1" Background="Tan">
                <StackPanel Orientation="Horizontal">
                    <StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <!-- Controls are bound to Task properties. -->
                            <TextBlock FontSize="16" Foreground="MidnightBlue" Text="{Binding Name}" 
                               Margin="0,0,10,0" VerticalAlignment="Bottom" />
                            <TextBlock FontSize="12" Text="Due Date: " VerticalAlignment="Bottom"/>
                            <sdk:DatePicker SelectedDate="{Binding DueDate, Mode=TwoWay}" VerticalAlignment="Bottom" />
                            <TextBlock FontSize="12" Text="    Complete:" VerticalAlignment="Bottom" />
                            <CheckBox IsChecked="{Binding Complete, Mode=TwoWay}" 
                                  VerticalAlignment="Center" />
                        </StackPanel>
                        <TextBlock FontSize="12" Text="Notes: " />
                        <TextBox FontSize="12" Text="{Binding Notes, Mode=TwoWay}" 
                             Width="420" TextWrapping="Wrap"/>
                    </StackPanel>
                </StackPanel>
            </Border>
        </DataTemplate>
        <!-- End row details section. -->
    </sdk:DataGrid.RowDetailsTemplate>
</sdk:DataGrid>


Silverlight

Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft