Back to Devexpress

DXDataTemplateTrigger Class

wpf-devexpress-dot-xpf-dot-dxbinding-cf83b840.md

latest2.6 KB
Original Source

DXDataTemplateTrigger Class

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

Namespace : DevExpress.Xpf.DXBinding

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

NuGet Package : DevExpress.Wpf.Core

Declaration

csharp
public class DXDataTemplateTrigger :
    DXTriggerBase
vb
Public Class DXDataTemplateTrigger
    Inherits 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.

xaml
<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"/>

Inheritance

Object DispatcherObject DependencyObject Freezable DXTriggerBase DXDataTemplateTrigger

See Also

DXDataTemplateTrigger Members

DevExpress.Xpf.DXBinding Namespace