Does it make sense for a ViewModel to have a collection of ViewModels in WPF?

I have a WPF application where all the functionality of the application is placed inside tabs. Similar to web browsers, each tab is one instance of the actual application.

I currently have a view model for the whole application window MainWindowViewModel

, but I am wondering if it is possible to force this view model to have an observable collection of these table view models?

+3


source to share


1 answer


Yes, this approach sometimes makes sense in this type of scenario. When you have a collection of list items that are native views, nested views make it easy to determine which list item you are working with at any given time.

If the collection was just a collection of simple objects with a few properties, it wouldn't be worth the overhead of using additional view modes.



However, it looks like each of these tabs will have their own behavior and individual viewing modes.

This adds some complexity if you need to communicate between views. If you are not already using any event aggregator, you may need to move this path at some point.

+5


source







All Articles