Prism Screencasts on Channel 9 Part 2
April 10th, 2009
Creating a modular application using Prism V2 – Screencast 3/4 : Implementing views and services
Step 5 – Creating the ViewModel
- View model contains all the bindable elements that will appear in the view.
- Use a ViewModel to allow easy testing and styling.
- Just a normal class exposing data via properties.
- Use constructor injection to add the ViewModel to the View and set the View’s DataContext to be the ViewModel.
- Add HeaderData property to the ViewModel – if being used in tabs.
- Step 6 – Implementing Services
- Create interface for service to allow testing in isolation/swapping of concrete types etc.
- Add service interface to constructor for ViewModel using constructor injection.
- Initialise data using the service interface.
- Add the unity container to the constructor for the module class.
- In the module initialisation code register the Service with the unity container using the following code
container.RegisterType<IServiceInterface, ServiceClass>();
- If you want a singleton service use this instead
Creating a modular application using Prism v2 – Screencast 4/4 : Decoupled Communication
This video covered the event aggregator and how to publish/subscribe to loosely coupled events. Pretty much covered the same stuff as my post on event aggregation.