I have a XamDataTree defined and am using an object that is derived from the ObservableCollection<T> object.
public class NonWorkingParentItems : ObservableCollection<NonWorkingParentItem>, INotifyCollectionChanged,
INotifyPropertyChanged
{
...
}
When I create the object, add items to it and then set the ItemsSource on the XamDataTree the data never shows up in the tree.
If I create the ObservableCollection<NonWorkingParentItem> and set the ItemsSource to this everything works fine.
While I know I can use this method it falls out of line to how we code things and it really does not make sense why the other would not work.
I have attached a sample project that demonstrates the issue.
I would appreciate an explaination and/or a solution to resolve this issue.
Your issue is that your NonWorkingParent constructor does not take the input string (sName) and set it to anything. So all the Name properites values are null/empty strings.
Modify your ctor to:
sName)
.Name = sName;
durantpc & Darrel,I was looking for a confirmation that XamDataTree's ItemsSource could handle ObservableCollection<T> derived classes. So I've found this post and I used the attached project to make some tests.
The solution Darrel suggested doesn't fix the 'add child' behaviour: the tree is still having troubles with child nodes. This was exactly my case: tree was succesfully loading parent nodes, but it didn't expand to children.
So I've simplified the original data items in the attached project and finally I obtained a solution that does work! :) I'm attaching it, maybe it could be useful for someone who's having the same problem.
Bye, Maria
Hello Maria,
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.