This documentation is archived and is not being maintained.

DataGrid.RowDetailsTemplate Property

Gets or sets the template that is used to display the row details.

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

public DataTemplate RowDetailsTemplate { get; set; }
    <DataTemplate .../>

Property Value

Type: System.Windows.DataTemplate
The template that is used to display the row details. The registered default is null. For more information about what can influence the value, see DependencyProperty.

You can customize the data presentation in the DataGrid by adding a row details section. Adding a row details section enables you to group some data in a template that is optionally visible or collapsed.

You define the row details template as either inline XAML or as a resource. A data template that is added as a resource can be used throughout the project without re-creating the template. A data template that is added as inline XAML is only accessible from the control where it is defined.

You can modify the RowDetailsTemplate before it is displayed by handling the LoadingRowDetails event. You should handle the UnloadingRowDetails event to undo changes that are made while loading the row details.

The following example shows a DataGrid with a RowDetailsTemplate defined inline. The DataGrid displays three values in each row and three more values in the details section when the row is selected. This example is part of a larger example available in the How to: Add Row Details to a DataGrid Control topic.

<Window x:Class="WpfApplication1.MainWindow"
        Title="MainWindow" Height="350" Width="525" 
        <DataGrid Name="dataGrid1" IsReadOnly="True" AutoGenerateColumns="False" >
                <DataGridTextColumn Header="Company Name" Binding="{Binding CompanyName}"></DataGridTextColumn>
                <DataGridTextColumn Header="Contact First Name" Binding="{Binding FirstName}"></DataGridTextColumn>
                <DataGridTextColumn Header="Contact Last Name" Binding="{Binding LastName}"></DataGridTextColumn>
                    <Border BorderThickness="0" Background="BlanchedAlmond" Padding="10">
                        <StackPanel Orientation="Vertical">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock FontSize="12" Text="Email: " VerticalAlignment="Center" />
                                <TextBlock FontSize="16" Foreground="MidnightBlue" Text="{Binding EmailAddress}" VerticalAlignment="Center" />
                            <StackPanel Orientation="Horizontal">
                                <TextBlock FontSize="12" Text="Phone: " VerticalAlignment="Center" />
                                <TextBlock FontSize="16" Foreground="MidnightBlue" Text="{Binding Phone}" VerticalAlignment="Center" />
                            <StackPanel Orientation="Horizontal">
                                <TextBlock FontSize="12" Text="Sales Person: " VerticalAlignment="Center" />
                                <TextBlock FontSize="16" Foreground="MidnightBlue" Text="{Binding SalesPerson}" VerticalAlignment="Center" />

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.