Search code examples
c#wpfmvvmtreeview

Strategy to keep TreeView ViewModel and model in sync in C# WPF MVVM


I try to keep a TreeView in sync with my data layer during drag-drop operations.

Questions

  1. Should operations in the TreeView like drag-and-drop act on the ItemViewModel or should these be send to the service/data layer and then update the ItemViewModel?
  2. I currently have two Tree structures, one in my data layer and one in my view layer. With regard to question 1 is this the proper way to do this?

Solution

  • I found the TreeListBox example in https://github.com/PropertyTools/PropertyTools/tree/develop/Source/Examples/TreeListBox a helpful example. It has separation between model and viewmodel and dragdrop/delete functions while keeping model in sync