I’m trying to bind a simple tree structure to an ItemsControl’s itemsSource in a Win 8 (formerly called) Metro app.
My structure implements the INotifyPropertyChanged interface, and also notify, when any of it’s children changed.
I tried to make a converter, which flatten my tree to an ObservableCollection, but after the binding created, it doesn’t refresh.
I made the following test project to show what I would like:
https://skydrive.live.com/redir?resid=970FFC53F4B7A598!146
The problem in this simple project, that if you press the Add button on the bottom app bar, it’s create a new child in the hierarchy, but the ListView does not refresh.
What I miss, or how can I do this?
This should be fairly simple using a
DataTemplate, e.g.Apply it implicitly via the
ItemsControl.Resources(so it gets applied to the innerItemsControlas well.If you just want the leaves or take issue with items not being single units you could construct a
CompositeCollection, other than the converter which creates anObservableCollectionwhich is never modified because only the view has a reference to it, you can wrap the original collection viaCollectionContainers, notifications will be preserved.