May 18, 2010 at 9:05 AM
Edited May 18, 2010 at 9:05 AM
Code with sample can be found here:
The code will work in .NET 3.5 but is currently targeted for .NET 4.
This project is unchanged except for adding an assembly directive: [assembly: InternalsVisibleTo("CoreLibWpfClient")]
Contains all extensions to the WpfApplicationFramework. It contains the following components:
A view model that does not require a view object to be injected into the constructor. The view model will be displayed using the view specified in the Presentation layer using <DataTemplate>.
Defines the base contract for a view to act as a dialog within the application.
- DialogPresenter: Hooks up an IDialogView with a ViewModel and
manages the dialog’s lifecycle.
Extends the Window class and provides the implementation of IDialogView. All other dialog types e.g. modal, splash screen extend from this.
This is largely the same as you would expect for a WAF application except that the only view interfaces that need to exist are those that represent each type of dialog (e.g. modal/splash screen).
The main changes are:
- Views for view models always extend UserControl. This means that the same ViewModel can be displayed normally or in a dialog within the same application.
- Specific implementations of each dialog type are defined here and exported according to the relevant interface type.
- Views are bound to ViewModels using <DataTemplate>
The main issue I have with this setup is that I’m not sure who should be handling the commands of the view model: The Vm itself, the DialogPresenter, or the Controller? I suppose it depends on the specific