I want to create a TreeView that have 'ItemsSource=ObservableCollection...".
I created a Style for TreeViewItem that contains DataGrid with controls bound to the items in the ObservableCollection. For example CheckBox that bound to a property of the item.
I want to create a Trigger that in case that the item property have specific value it will change property value of the control:
<Style TargetType="{x:Type TreeViewItem}" x:Key="GridItemStyle" x:Name="GridItemStyle2">
<Setter Property="Template" >
<Setter.Value>
<ControlTemplate TargetType="{x:Type TreeViewItem}">
<Border Background="Red" BorderBrush="Yellow" BorderThickness="3" Margin="2,10,0,0">
<StackPanel Background="Red" Margin="10,10,10,10" Orientation="Horizontal">
<StackPanel.Triggers>
<Trigger Property="{Binding IsSucceed}" Value="True">
<Setter Property="Background" Value="Blue"/>
</Trigger>
</StackPanel.Triggers>
<TextBlock Margin="0,0,10,0" Text="{Binding Path=time, StringFormat={}\{0:dd/MM/yyyy hh:mm:ss:fff\}, Mode=OneWay}"/>
<TextBlock Margin="0,0,10,0" Text="{Binding milisecond}"/>
<TextBlock Margin="0,0,10,0" Text="{Binding address}"/>
<TextBlock Margin="0,0,10,0" Text="{Binding IsSucceed}"/>
<TextBlock Margin="0,0,10,0" Text="{Binding statues}"/>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
The get exception in runtime because of the Trigger:
<Trigger Property="{Binding IsSucceed}" Value="True">
<Setter Property="Background" Value="Blue"/>
</Trigger>
How do I solve it?