Application Components

Mar 3, 2010 at 11:23 AM


My WAF application is getting quite big now and I need to encapsulate specific components (each with their own application, domain, and presentation pieces). What is your preferred strategy for doing this?

Mar 5, 2010 at 9:01 PM

I use a modular design for bigger applications which is very similar to the one the Microsoft p&p team recommends:

Mar 5, 2010 at 9:37 PM

This is good guidance but at a fairly high-level. I can't immediately see how to apply this to a WAF project. It may be a good idea to show how to apply these principles in a sample project.

Mar 12, 2010 at 5:11 PM

I like your idea to provide a sample project that shows how to apply modularization with WAF and MEF. I consider it for version 2.0 of WAF.

Mar 13, 2010 at 9:03 AM

What are your plans for 2.0?

You may remember I was struggling with the need to inject Views into the ViewModel, and the use of GetViewModel<T>(). I have actually come up with a solution in WAF using a DialogPresenter which I think is cleaner, more flexible, and still in line with the principles of WAF. It allows an application to easily support multiple dialog types (e.g. splashscreen, modal, non-modal).

It would be better explained with a sample. I'll try and put one together soon.

May 18, 2010 at 3:24 AM

Hello Skina,

If you have some time can you show us an example of your DialogPresenter.




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:

  • SimpleViewModel: 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>.
  • IDialogView: 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.
  • Dialog: 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 application.