DataGrid.RowDetailsTemplate Property
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Gets or sets the template that is used to display the row details.
Namespace: System.Windows.Controls
Assembly: PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
<object> <object.RowDetailsTemplate> <DataTemplate .../> </object.RowDetailsTemplate> </object>
Property Value
Type: System.Windows.DataTemplateThe 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" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded"> <Grid> <DataGrid Name="dataGrid1" IsReadOnly="True" AutoGenerateColumns="False" > <DataGrid.Columns> <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> </DataGrid.Columns> <DataGrid.RowDetailsTemplate> <DataTemplate> <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> <StackPanel Orientation="Horizontal"> <TextBlock FontSize="12" Text="Phone: " VerticalAlignment="Center" /> <TextBlock FontSize="16" Foreground="MidnightBlue" Text="{Binding Phone}" VerticalAlignment="Center" /> </StackPanel> <StackPanel Orientation="Horizontal"> <TextBlock FontSize="12" Text="Sales Person: " VerticalAlignment="Center" /> <TextBlock FontSize="16" Foreground="MidnightBlue" Text="{Binding SalesPerson}" VerticalAlignment="Center" /> </StackPanel> </StackPanel> </Border> </DataTemplate> </DataGrid.RowDetailsTemplate> </DataGrid> </Grid> </Window>
Windows 8 Consumer Preview, Windows Server 8 Beta, Windows 7, Windows Server 2008 SP2, Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.