I am using a Wpf TreeView, in this I can add TreeViewItems dynamically. Is there any way to know when the tree is updated? I tried with the CollectionChanged event of the ObservableCollection that I binded with the TreeView but that didn't work.
Edit:
My code is in like this:
class Temp
{
public void Load()
{
DeriveA d1 = new DeriveA();
DeriveB d2 = new DeriveB();
DeriveB d3 = new DeriveB();
DeriveC d4 = new DeriveC();
DeriveC d5 = new DeriveC();
d1.Items.Add(d2);
d1.Items.Add(d3);
d2.Items.Add(d4);
d2.Items.Add(d5);
List = new ObservableCollection<object>();
List.Add(d1);
tree.ItemsSource = List;
DeriveC d6 = new DeriveC();
d3.Items.Add(d6); //At this point, I want to know that List got updated
}
public ObservableCollection<object> List
{
get;
set;
}
}
class Base
{
ObservableCollection<Base> Items = new ObservableCollection<Base>();
}
class DeriveA : Base
{
}
class DeriveB : Base
{
}
class DeriveC : Base
{
}
How can I find when List property get updated at any level?