Skip to main content
A newer version of this page is available. .

DXDataTemplateTrigger Class

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

Namespace: DevExpress.Xpf.DXBinding

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

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