Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DXDataTemplateTrigger Class

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

Namespace: DevExpress.Xpf.DXBinding

Assembly: DevExpress.Xpf.Core.v24.2.dll

NuGet Package: DevExpress.Wpf.Core

#Declaration

public class DXDataTemplateTrigger :
    DXTriggerBase

#Remarks

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.

#Example

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}"/>
</DXDataTemplateSelector>
...
<ListBox Width="400" Margin="10"
         ItemsSource="{Binding Source={StaticResource myTodoList}}"
         ItemTemplateSelector="{StaticResource myDataTemplateSelector}"
         HorizontalContentAlignment="Stretch"/>
See Also