Skip to main content

DXDataTemplateTrigger Class

A trigger that returns a data template when a custom condition is satisfied.

Namespace: DevExpress.Xpf.DXBinding

Assembly: DevExpress.Xpf.Core.v23.1.dll

NuGet Package: DevExpress.Wpf.Core


public class DXDataTemplateTrigger :


The DXDataTemplateTrigger requires specifying both the DXTriggerBase.Binding and DXTriggerBase.Value properties to return a data template that satisfies the condition (that is, the specified property is set to a specified value). When both the Binding and Value properties are not specified, the DXDataTemplateTrigger serves as the default template source.

The last positive trigger provides the template (like regular WPF triggers).

You can assign a template to DXDataTemplateTrigger explicitly or as a static resource only. Dynamic resources are not supported.


The code sample below illustrates how to select different data templates for different ListBox items using the DXDataTemplateSelector.

<DXDataTemplateSelector x:Key="myDataTemplateSelector">
    <DXDataTemplateTrigger Binding="{Binding Priority}" Value="1" Template="{StaticResource importantTaskTemplate}"/>
    <DXDataTemplateTrigger Template="{StaticResource myTaskTemplate}"/>
<ListBox Width="400" Margin="10"
         ItemsSource="{Binding Source={StaticResource myTodoList}}"
         ItemTemplateSelector="{StaticResource myDataTemplateSelector}"
See Also