I have a TreeView bound to an ObservableCollection with a ViewModel. The TreeView includes folder-like elements that will have child items. Most times opening the app we won't need to view those child items so I'm not filling them in when the app opens, rather each folder-like item has a place-holder item to indicate there ARE child items. I've included this in my TreeView XAML to call a routine when the TreeViewItem is expanded:
TreeViewItem.Expanded="TVExp"
That is working fine but the new child items do not show in the TreeView unless I call .Refresh() on the data items.
Now, ObservableCollection states: "Represents a dynamic data collection that provides notifications when items get added, removed, or when the whole list is refreshed." But that doesn't seem to really be the case as the child items added to the data don't show in the UI.
It appears I have to implement the INotifyCollectionChanged interface. True? VisualStudio (amazingly!) will add code designed to help with this but I'm not sure where to start. Does it get implemented on the ViewModel or on the ObservableCollection, or both?
I imagine it's implemented something like INotifyPropertyChanged but I've not manged to find a good example that's simple enough for my newbee .net knowledge to follow.
Can someone give an example of that, or point me to one?
Many thanks,
Ken