-
Notifications
You must be signed in to change notification settings - Fork 1
Mvvm Framework
kobi2294 edited this page May 19, 2019
·
9 revisions
The Mvvm Kit is a strongly opinionated framework the helps to build advanced WPF applications.
To create an MvvmKit application, do the following:
- Create a new project using the
Mvvm Kit Project Template
for visual studio - Create Components using the
Mvvm Kit Component Template
for visual studio - The view model is inherited from
ComponentBase
, add bindable properties and delegate commands to it. - Each Component comes with a resource dictionary for design time data, add design time instances of your view model
- Draw the view using the Design Time Data.
- Creates Model services by inheriting from
ServiceBase
- Add the services to the Unity container in the Bootstrapper.
- Consume the services in the view models by declaring them in the
Inject
Method. - Expose service state changes using
AsyncEvent
- Define global regions in the application using the GlobalRegions static class
- Define region hosts in the container view by using the GlobalHost attached properties
- If the region has a small constant set of possible views, you can define a router for that region and use it for navigation. Otherwise, you can perform navigations directly on the region using the region manager.
- You can define Dialog Components by inheriting the view model from
DialogBase
instead ofComponentBase
. - You can run the dialogs and collect the results using the regions manager and a dedicated dialogs host.
- Dependency Injection using Unity
- Region Based Navigation
- Async Services
- Use the BootsrtapperBase class as base class to create your application bootstrapper
- Use the ComponentBase class as base class to all component view models.
- Use the BindableBase class as base class to create small non navigateable, very basic view models (bindables)
- Use the DelegateCommand class to create instances of commands, that implement the
ICommand
interface
- The
IViewResolver
interface contains a single method that accepts a view model type and returns the matching view type. You may implement it in order to define a rule that matches view and view model types. - The
DefaultViewResolver
class is a default such implementation that removes theVm
postfix and replaces it withView
, which answers to the naming standart of the MvvmKit. - The
DataTemplateWrapper
class is an internal static class that contains a method that accepts view model type and view type, and builds a data template for the view model type, that creates an instance of the view type. - The
ViewTemplateSelector
class is aDataTemplateSelector
that creates a view for a view model content. It uses an injectedIViewResolver
to find the matching view type, and then constructs theDataTemplate
usingDataTemplateWrapper