[Original]
I have a listbox which has its itemssource (this is done in the code behind on as the window is created) databound to an observable collection. The List box then has the following data template assigned against the items:
usercontrol.xaml
...
<ListBox
x:Name="communicatorListPhoneControls"
ItemContainerStyle="{StaticResource templateForCalls}"/>
...
app.xaml
...
<Style x:Key="templateForCalls" TargetType="{x:Type ListBoxItem}">
<Setter Property="ContentTemplate" Value="{StaticResource templateRinging}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Path=hasBeenAnswered}" Value="True">
<Setter Property="ContentTemplate" Value="{StaticResource templateAnswered}"/>
</DataTrigger>
</Style.Triggers>
</Style>
...
When the observable collection is updated with an object, this appears in the listbox with the correct initial datatemplate, however when the "hasBeenAnswered" property is set to true (when debugging i can see the collection is correct) the datatrigger does not re-evaluate and then update the listbox to use the correct data template.
I have implemented the INotifyPropertyChanged Event in my object, and if in the template i bind to a value, i can see the value update. Its just that the datatrigger will not re-evaluate and change to the correct template.
I know the datatrigger binding is correct because if i close the window and open it again, it will correctly apply the second datatemplate, because the "hasBeenAnswered" is set to True.
[edit 1]
Following on from comments made by @Timores i've tried the following:
usercontrol.xaml
...
<ListBox
x:Name="communicatorListPhoneControls"
ItemTemplate="{StaticResource communicatorCallTemplate}"/>
...
app.xaml:
...
<DataTemplate x:Key="communicatorCallTemplate">
<Label x:Name="test">Not answered</Label>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Path=hasBeenAnswered}" Value="True">
<Setter TargetName="test" Property="Background" Value="Blue"/>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
...
What happens now is similar to the first example, when a call comes in the "Not answered" label shows (one per call that exists as this is a listbox - normally when the window loads there will be no calls), the call is then answered and the propery "hasBeenAnswered" is set to true, yet the "Not Answered" remains the same. If i close the window, and re-open it again (with the active call still with the property hasBeenAnswered set to true) the background is then blue. So it would appear to me like the datatrigger is simply not being run, until the window is re-run.