WPF Treeview Using Catel 4

2019-08-14 22:38发布

问题:

Can anyone guide me in using Catel 4 and a WPF TreeView control? I'm trying to create something like the VS solution explorer. I have created models and VMs for each level of the tree.

When I add a hierarchical data template (HDT) and use the VM types for the DataType parameters, I get a tree showing the top-level collection member types. That is, WPF couldn't match the ItemsSource collection types to my HDT. If I change the HDT to use the model types, the TreeView behaves properly, but now my VMs aren't being used.

Thanks.

-reilly.

回答1:

I don't think it's a good idea to make every element inside the tree a view model (performance wise). A treeview (like the solution explorer) should be a single view model with models that contain nested models. So your model will be a complete object graph representing the items in the tree.



标签: catel