I have a custom TreeListView
(based on a TreeView
) in my WPF-Application. The ItemSource
is bound to an ObservableCollection<Node>
where Node
is a custom class that is based on a TreeListViewItem
and therefore a TreeItem
. It contains the values that should be displayed.
The Binding of the columns to the values in the Node
works when new Nodes are loaded (I implemented a lazyload, the ItemSource changes often (new Node
s added) and so does the UI), but when a value in the Node changes, the value in the UI doesn't change.
I created a DataTemplate
with triggers to test the behaviour:
<DataTemplate x:Key="CellTemplate_Speicherplatz">
<TextBlock Name="tbSpeicherplatz" TextAlignment="Right">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Text" Value="{Binding RecSpeicherplatz, RelativeSource={RelativeSource AncestorType={x:Type k:Node}}}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding DataContext.IsProcessing, RelativeSource={RelativeSource AncestorType={x:Type Window}}}" Value="False">
<Setter Property="Text" Value="{Binding RecSpeicherplatz, RelativeSource={RelativeSource AncestorType={x:Type k:Node}}}"/>
</DataTrigger>
<DataTrigger Binding="{Binding DataContext.IsProcessing, RelativeSource={RelativeSource AncestorType={x:Type Window}}}" Value="True">
<Setter Property="Text" Value="..."/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</DataTemplate>
This results in the following behaviour: while IsProcessing
is true, the text in the UI is "...". When IsProcessing
changes to false, the old value of RecSpeicherplatz
is shown even though the variable has been changed in the Node
.
Could somebody please explain why it is behaving like that and how to solve this?
Does the Node class implement the INotifyPropertyChanged interface? Do you raise the PropertyChanged event when the property RecSpeicherplatz changes?