I have a TreeView whose ItemsSource is binded to StaticResource, which is a class. This has worked fine for me, but now I have a function that updates the lowest level of the TreeView with possible different values and this update needs to be shown immediately. I have accomplished similar tasks like binding IsChecked of checkboxes in the tree to a value in a model, as well as textblock text binding to values in a model.
Here is the code for reference of the TreeView in XAML:
<!-- TREE VIEW ON LEFT HAND SIDE. LOADS TREEVIEWPARENTS, WHICH HAVE ORDER ATTRIBUTE CHILDREN -->
<DockPanel Name="test1" Margin="10,10,0,10" VerticalAlignment="Stretch" Grid.Row="3" Grid.RowSpan="6" Grid.Column="0">
<DockPanel.Resources>
<local:CheckBoxCommand x:Key="cbc"></local:CheckBoxCommand>
<src:TreeViewFilter x:Key="MyList" />
<!-- PARENTS OF THE TREEVIEW -->
<HierarchicalDataTemplate DataType="{x:Type src:TreeViewParent}" ItemsSource="{Binding Path=OrderAttributes}">
<TextBlock Text="{Binding Path=NameAndCount}" FontSize="24"/>
</HierarchicalDataTemplate>
<!-- CHILDREN OF THE PARENTS. THESE ORDER ATTRIBUTES HAVE CHILDREN OF THEIR OWN -->
<HierarchicalDataTemplate DataType="{x:Type src:OrderAttribute}" ItemsSource="{Binding Path=OrderAttributes}">
<StackPanel Name="test" Orientation="Horizontal" VerticalAlignment="Center">
<CheckBox Command="{StaticResource cbc}"
CommandParameter="{Binding Path=NameAndParent}" Visibility="{Binding Path=CheckBoxVisible}" IsChecked="{Binding Path=isChecked}" VerticalAlignment="Center">
</CheckBox>
<TextBlock Text="{Binding Path=NameAndCount}" FontSize="16"/>
</StackPanel>
</HierarchicalDataTemplate>
</DockPanel.Resources>
<TreeView Name="treeView1" BorderThickness="2" ItemsSource="{Binding Source={StaticResource MyList}, NotifyOnSourceUpdated=True}" TreeViewItem.Selected="filterByBatchStatus"/>
</DockPanel>
So as you can see, the ItemsSource is binded to a StaticResource MyList, which is really just a key for a Name of the class TreeViewFilter. The reason this has been working for me is because The "TreeViewParents" and the "OrderAttributes" that the tree contains are all created in the constructor of the TreeViewFilter class. But now I want to be able to update values in the lowest heirarchy of the tree and have them be shown visibly.
My guess is that I can do this similar to how I did other bindings with visual updates, using INotifyPropertyChanged and firing propertyChanged events or something along those lines? Any Ideas?
(Also, that NotifyOnSourceUpdated=True in the binding is something I was just messing with for this problem, dont know how that works)