I'm learning WPF and MVVM and trying to stress good design. I have lots of experience with WinForms and C#. This is conceptual so I don't think I need to post code.
I have a xaml Window that manages "Profiles". On the left half is a custom Control treeview bound to a ViewModel that reads a database and creates a heirarchy of profiles. The ViewModel for the individual profiles contains a database ID among other things. The right half is another custom control with a ListView and its own ViewModel that reads the database for individual Profile information.
Both halves work fine independently, but now I want to tie the treeview selection with the listview so that the information in the listview reflects the treeview selection. What is the best way to do this?
The treeview viewmodel provides a profile ID that can be used to lookup profile information in the listview. Again, the goal is to just to tie these two together. I feel like I have a few options:
-The treeview's viewmodel could call a static method in the listview viewmodel that updates the profile.
-The whole page could contain a viewmodel that has member viewmodels for both components.
-I could somehow "route" the treeviewss viewmodel's known selected profile to the listview control in the xaml file.
All of these options feel dirty. Again I'm learning here, and want to stress good design as these little details dictate larger decisions later on.
And ideas?
Thanks!