Skip to main content

DetailDescriptorBase.ContentTemplate Property

Gets or sets the template specifying the entire or partial content of a Detail.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v23.2.Core.dll

NuGet Package: DevExpress.Wpf.Grid.Core

Declaration

public DataTemplate ContentTemplate { get; set; }

Property Value

Type Description
DataTemplate

A DataTemplate object specifying the Detail section’s content.

Remarks

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.

Grid-Master-Detail-Content-Template

Example

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:

  • The ContentDetailDescriptor tab displays the custom content only.
  • The DataControlDetailDescriptor tab displays the custom content above the detail GridControl.

WPF Data Grid - Display Chart Control in Grid Details

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.

See Also