Differences between MVVM Foundation and MVVM Toolkit?

Sep 6, 2009 at 7:53 AM
Edited Sep 6, 2009 at 7:54 AM

Can someone explain the differences between the MVVM Foundation and the MVVM Toolkit (http://wpf.codeplex.com/Wiki/View.aspx?title=WPF%20Model-View-ViewModel%20Toolkit)? They seem to have a lot in common. Do they compliment each other or should I just use one or the other?

Thanks,

-Dan

Coordinator
Sep 8, 2009 at 4:29 PM

I haven't looked too deeply into the WPF Toolkit, but from my understanding, it focuses more on controls than utility/base classes.  I think they complement each other.

Sep 8, 2009 at 7:25 PM

Thanks, Josh. Since posting my question, I've downloaded both packages and taken a look at the contents. Here's what I can gather so far.

The MVVM Toolkit contains the following classes (with associated "summary" definitions):

- DelegateCommand - This class allows delegating the commanding logic to methods passed as parameters, and enables a View to bind commands to objects that are not part of the element tree.

- DelegateCommand<T> - This class allows delegating the commanding logic to methods passed as parameters, and enables a View to bind commands to objects that are not part of the element tree.

- CommandManagerHelper - This class contains methods for the CommandManager that help avoid memory leaks by using weak references.

- CommandReference - This class facilitates associating a key binding in XAML markup to a command defined in a View Model by exposing a Command dependency property. The class derives from Freezable to work around a limitation in WPF when data-binding from XAML.

The MVVM Foundation contains the following classes (with associated "summary" definitions):

- RelayCommand - A command whose sole purpose is to relay its functionality to other objects by invoking delegates. The default return value for the CanExecute method is 'true'.

- RelayCommand<T> - A command whose sole purpose is to relay its functionality to other objects by invoking delegates. The default return value for the CanExecute method is 'true'.

- ObservableObject - This is the abstract base class for any object that provides property change notifications.

- PropertyObserver - Monitors the PropertyChanged event of an object that implements INotifyPropertyChanged, and executes callback methods (i.e. handlers) registered for properties of that object.

- Messenger - Provides loosely-coupled messaging between various colleague objects.  All references to objects are stored weakly, to prevent memory leaks.


Discussion:

So it looks like the DelegateCommand and RelayCommand are pretty similar, though the DelegateCommand uses a CommandManagerHelper to avoid memory leaks, while it appears the RelayCommand just uses the CommandManager directly.

The remaining classes appear to be entirely complimentary, unless I'm misunderstanding what they do.

So, I guess a nice package would be: DelegateCommand, DelegateCommand<T>, CommandManagerHelper, CommandReference, ObservableObject, and PropertyObserver, Messenger.