I'm trying to switch between 2 templates on the basis of a data trigger. But I app crashes with the "Object reference not set to an instance of an object." If I comment out the setter for the template it runs fine.
Here's my XAML:
<Style x:Key="ListViewItemStyle" TargetType="{x:Type ListViewItem}">
<Setter Property="Template" Value="{StaticResource Default}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Path=FlagVar}" Value="true">
<Setter Property="Template" Value="Error"/>
<Setter Property="Background" Value="{DynamicResource ListErrorBackgroundColor}"/>
<Setter Property="IsSelected" Value="False"/>
</DataTrigger>
</Style.Triggers>
</Style>
EDIT- The above styling is in a ResourceDictionary which is merged into the consuming XAML.