I am working on a simple application and trying to use the goodies from the Catel framework.
What I need to do is a following:
- Display a GUI with some settings the user can change
- When the user click a start button, collect the data and use it in the execution of some code.
- When the user closes the application I want to save the settings. When the application opens I want to load settings if they exist already.
- Some actions from the Main window should cause the child View/ViewModels to refresh
I want to use MVVM and Catel offers many helpful classes. Unfortunately, I am relatively new to MVVM and the framework and a little at loss.
What I did (and hopefully is not too far off) is:
- Create 2 main model classes based on SaveableDataObjectBase (and some support model classes used in the main model classes)
- I implemented 2 ViewModels (one for each main model) that instantiate an instance of the model class
- VM contains additional properties and commands
- Some of the "additional properties" are for example, a list of possible selection values that go-to/selected-by the model
- I implemented 2 View classes (user controls) that request corresponding VM classes
- Implemented a main View and ViewModel
- View contains the 2 views from above and some menu etc and the start/stop and cancel buttons
- VM contains command
What would be a good approach to get the data from the VMs?
I guess I can create the Model classes in application startup register them in IOC and then get them in the VMs (resolve) then also get the same instances in the main VM and when the application shut down save them.
I'll be happy to hear how something like this is "best" implemented using features of Catel.