wpf-119428-mvvm-framework-dxdatatemplateselector.md
The DXDataTemplateSelector is a declarative way to implement DataTemplateSelector.
The DXDataTemplateSelector allows you to define a simple template selection logic in XAML, so you do not need to create a DataTemplateSelector ancestor in code-behind. The DXDataTemplateSelector works like WPF triggers.
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"/>