I'm prototyping a TreeView using a contained SfListView.
I have a data model that maps a Tree hierarchy to an ObservableCollection and inserts/removes items as node's are expanded and collapsed. SfListView.ItemsSource is set to the ObservableCollection.
NOTE: The attached zip file contains code and xaml excerpts referenced below.
SfListView.ItemTemplate is set to a DataTemplate. (ItemTemplate.original.xaml)
At this point, everything works expected, items are populated and removed when nodes are expanded/collapsed and SelectedItem is being tracked accordingly.
Next I want to support a ContentPresenter for the node's value instead of displaying a simple text label.
Here's the steps I took:
I've debugged down to the OnContentChanged and confirmed I receive a TreeViewItemCell and created its Content but no items are displayed in the SfListView. When I view the SfListView in the LiveVisualTree, I see the VisualContainer populated with a list of my ListViewItemsExt displayed as [TreeViewItemsGenerator+ListViewItemExt]
Is this the right approach? If so, what am I missing. If not, what's the proper way to accomplish this?
Hi Daniel Travison,
Thank you for reporting
your query, and we were able to understand your scenario. We attempted to
implement the code for your requirement using the code changes you provided;
however, we encountered difficulty in understanding the purpose of the TreeView
and TreeItem classes.
To assist you better, could you please provide us with the code changes you made for TreeView and TreeItem classed? Additionally, it would be helpful if you could share the initialization code for SfListView and where you set the ItemTemplate for the ListView.
Here, we have attached a
sample of what we tried so far in an attempt to meet your requirements. Please
share the requested details or if possible, please modify the attached sample
with missed code customizations. It would be very helpful for us to analyze the
query further.
Regards,
Riyas Hameed M
I think it will be easier to put together a stand-alone sample that incorporates the tree components and illustrates the DataItem/ContentPresenter issues. I should have it ready sometime tomorrow and will reply with a repo.
I won't be able to publically share parts of the code so let me know how I can share it (e.g., a private repro, zip, etc.)
Thanks,.
Daniel Travison,
We have created a new ticket for further follow-up. Please follow the ticket created in your account for further assistance. As always, we will gladly assist you.