I am looking for a solution/mvvm framework that supports nesting ViewModels and Views. What I mean is:
- Each ViewModel derives from BaseViewModel
- ViewModels have properties that are of type BaseViewModel which are sub-ViewModels (nested inside parent ViewModel)
- Each ViewModel have corresponding View
- Views have ContentControl (control that can display templated view) corresponding to sub-ViewModels of corresponding ViewModel
- Now, when creating instance of ViewModel it is needed to pass appropriate instances of concrete sub-ViewModels. Views should be automatically resolved and nested (somehow) base on ViewModels structure.
I do not define somehow because there may be a lot of ways to do it.
I hope my idea is clear. This approach allows easy and dynamic creation of ViewModels and Views. Just create tree of ViewModels, for example in XML, and base on this create new functionality.
The questions are:
- Is there any mvvm framework (mvvmcross, catel) supporting such approach for Xamarin.Forms?
- How would you store tree of ViewModels - in XML, database tables, ...?
- How would you create instances of ViewModels - deserialization, dependency injection, ...?
- How to create Views and resolve (if framework does not support it)?