[Original]
I have ListBoxone that has it ItemsSource(this is done in the code behind when creating the window), data binding to ObservableCollection. ListBoxhas the following DataTemplateassigned against elements:
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>
</Setter>
</Style>
When an object is ObservableCollectionupdated by the object, it appears in ListBoxwith the correct start DataTemplate, however, when the property is hasBeenAnsweredset to true(when debugging, I see the collection correctly) it DataTriggerdoes not overestimate, and then updates ListBoxto use the correct one DataTemplate.
INotifyPropertyChanged , , . , DataTrigger .
, DataTrigger , , , , hasBeenAnswered true.
[edit 1]
, :
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>
</Label>
</DataTemplate>
, , , " " ( , , - , , ), , proptery hasBeenAnswered true, "Not Answered" . ( hasBeenAnswered true), . , datatrigger , .