This project has moved and is read-only. For the latest updates, please go here.

Model-View-ViewModel (MVVM) and Windows Forms

Sep 25, 2010 at 11:02 AM

I read often in the MVVM community that the Model-View-ViewModel Pattern works only with WPF/Silverlight applications. That’s not true.

MVVM is a design pattern. Per definition a design pattern shows a common solution in the object-oriented world. Such solutions can be applied in various platforms (WPF, WinForms, Java Swing, etc.). I agree that MVVM is best used with WPF/Silverlight because it leverages the strong data binding capabilities. However, Windows Forms supports data binding as well.

The WAF Windows Forms Adapter shows how to apply the Model-View-ViewModel Pattern in a Windows Forms application. It ships the same BookLibrary sample application as the WPF Application Framework (WAF) download. It just extends the sample application with an alternative Presentation layer implementation which uses Windows Forms instead of WPF.

This BookLibrary sample application proves that the Applications and Domain layer of a WAF-based application is really independent of WPF. This way it was possible to replace the WPF technology with Windows Forms by writing a new Presentation layer whereas the code of the lower layers aren’t even touched. As a result the Windows Forms Views uses the same ViewModel classes as the WPF Views does. That’s how a clean separation into distinct layers should be.


Feb 14, 2011 at 2:07 AM
Edited Feb 25, 2011 at 6:48 PM

EDIT: Nevermind.  It doesn't really matter.

Mar 2, 2011 at 6:39 PM
Edited Mar 2, 2011 at 6:53 PM

Is there any chance to have the WAF Windows Forms Adapter library extended with adapters for key event handling (already asked this in, sorry for the crosspost) and, while I'm at it, for attaching the WinForms ErrorProvider to INotifyDataErrorInfo?


Mar 4, 2011 at 7:26 PM

Hi DrJ,

1. You could handle the Key – Events in Windows Forms and execute the commands manually:

private void FirstnameBoxKeyDown(object sender, KeyEventArgs e)
    if (e.KeyCode == Keys.Enter)

2. The interface INotifyDataErrorInfo is only available for Silverlight at the moment. But the ErrorInfoProvider supports the IDataErrorInfo interface as it is shown in the BookLibrary.WinForms sample application.


Feb 9, 2012 at 6:22 PM

Hi everybody,

I am Pedro, I'm studing in Computer Engineering UTAD (Portugal), and within of work proposed in a course Programming Methodology III, I would like to participate in this forum discussion.