wpf-devexpress-dot-xpf-dot-grid-dot-detaildescriptorbase-3b2d009a.md
Gets or sets the template specifying the entire or partial content of a Detail.
Namespace : DevExpress.Xpf.Grid
Assembly : DevExpress.Xpf.Grid.v25.2.Core.dll
NuGet Package : DevExpress.Wpf.Grid.Core
public DataTemplate ContentTemplate { get; set; }
Public Property ContentTemplate As DataTemplate
| Type | Description |
|---|---|
| DataTemplate |
A DataTemplate object specifying the Detail section’s content.
|
The DataContext for the specified template is the master record, so you can easily display additional information about the parent object.
ContentTemplate is mostly used with the ContentDetailDescriptor, since it is specially designed to define this Detail section’s content. This is how non-grid details are displayed within a master-detail GridControl.
When using a DataControlDetailDescriptor or a TabViewDetailDescriptor, ContentTemplate can also be used to display additional information above the Detail Data Control or above Tabs, as shown in the following image.
This example displays the memo field and the Chart Control in grid details. The memo field displays data from the master row, and the chart is bound to detail data. The DataTemplate that contains these two controls is asigned to both ContentDetailDescriptor and DataControlDetailDescriptor:
View Example: Display Chart Control in Grid Details
<Window
x:Class="WpfApplication19.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
Title="MainWindow" Height="450" Width="800">
<!--region #ContentTemplate-->
<Window.Resources>
<DataTemplate x:Key="ContentDetail">
<Grid Margin="10,10,10,10">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Grid.Column="0">
<TextBlock Text="Notes:" FontWeight="Bold"/>
<TextBlock Text="{Binding Path=Notes}" TextWrapping="Wrap"/>
</StackPanel>
<dxc:ChartControl DataSource="{Binding Path=Orders}" Grid.Column="1" Height="200" Margin="10,10,10,10">
<dxc:SimpleDiagram2D>
<dxc:SimpleDiagram2D.Series>
<dxc:PieSeries2D ArgumentDataMember="Supplier" ValueDataMember="Quantity" LabelsVisibility="True">
<dxc:PieSeries2D.PointOptions>
<dxc:PointOptions>
<dxc:PointOptions.ValueNumericOptions>
<dxc:NumericOptions Format="Percent" Precision="0"/>
</dxc:PointOptions.ValueNumericOptions>
</dxc:PointOptions>
</dxc:PieSeries2D.PointOptions>
<dxc:PieSeries2D.LegendPointOptions>
<dxc:PointOptions Pattern="{}{A}"/>
</dxc:PieSeries2D.LegendPointOptions>
</dxc:PieSeries2D>
</dxc:SimpleDiagram2D.Series>
</dxc:SimpleDiagram2D>
<dxc:ChartControl.Legend>
<dxc:Legend Visibility="Visible"/>
</dxc:ChartControl.Legend>
</dxc:ChartControl>
</Grid>
</DataTemplate>
</Window.Resources>
<!--endregion #ContentTemplate-->
<Grid>
<dxg:GridControl x:Name="grid" AutoGenerateColumns="AddNew">
<dxg:GridControl.View>
<dxg:TableView AutoWidth="True" ShowGroupPanel="False"/>
</dxg:GridControl.View>
<dxg:GridControl.DetailDescriptor>
<dxg:TabViewDetailDescriptor>
<dxg:ContentDetailDescriptor ContentTemplate="{StaticResource ContentDetail}" HeaderContent="ContentDetailDescriptor"/>
<dxg:DataControlDetailDescriptor ContentTemplate="{StaticResource ContentDetail}" ItemsSourcePath="Orders">
<dxg:GridControl AutoGenerateColumns="AddNew">
<dxg:GridControl.View>
<dxg:TableView AutoWidth="True" DetailHeaderContent="DataControlDetailDescriptor" ShowGroupPanel="False" />
</dxg:GridControl.View>
</dxg:GridControl>
</dxg:DataControlDetailDescriptor>
</dxg:TabViewDetailDescriptor>
</dxg:GridControl.DetailDescriptor>
</dxg:GridControl>
</Grid>
</Window>
The following code snippets (auto-collected from DevExpress Examples) contain references to the ContentTemplate property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
wpf-data-grid-display-chart-control-in-grid-details/CS/WpfApplication19/MainWindow.xaml#L53
<dxg:TabViewDetailDescriptor>
<dxg:ContentDetailDescriptor ContentTemplate="{StaticResource ContentDetail}" HeaderContent="ContentDetailDescriptor"/>
<dxg:DataControlDetailDescriptor ContentTemplate="{StaticResource ContentDetail}" ItemsSourcePath="Orders">
wpf-data-grid-display-detail-content-in-tabs/CS/WpfApplication18/MainWindow.xaml#L27
</dxg:DataControlDetailDescriptor>
<dxg:ContentDetailDescriptor ContentTemplate="{StaticResource EmployeeNotes}" HeaderContent="Notes"/>
</dxg:TabViewDetailDescriptor>
wpf-data-grid-display-custom-content-in-grid-details/CS/WpfApplication18/MainWindow.xaml#L14
<dxg:ContentDetailDescriptor>
<dxg:ContentDetailDescriptor.ContentTemplate>
<DataTemplate>
wpf-data-grid-create-master-detail-grid-in-code/CS/MasterDetailInCode/MainWindow.xaml.cs#L38
ContentDetailDescriptor customDetail = new ContentDetailDescriptor();
customDetail.ContentTemplate = (DataTemplate)FindResource("notesTemplate");
customDetail.HeaderContent = nameof(Employee.Notes);
wpf-data-grid-create-master-detail-grid-in-code/VB/MasterDetailInCode/MainWindow.xaml.vb#L39
Dim customDetail As ContentDetailDescriptor = New ContentDetailDescriptor()
customDetail.ContentTemplate = CType(FindResource("notesTemplate"), DataTemplate)
customDetail.HeaderContent = NameOf(Employee.Notes)
See Also