This project is read-only.

CommandSink or ObservableObject

Sep 24, 2010 at 10:39 PM


I am still learning about MVVM and have a quick question.  I was using ObservableObject as the base class for all of my VMs.  However, I recently read an article by Josh describing the CommandSink class, and that if possible VMs should derive form that.

What it the best approach here?  I would guess it would be to base my V off of ObservableObject and embed an instance of CommandSink into my ViewModel class.

Just looking for what other people do since I am still new to this :)

Sep 24, 2010 at 10:46 PM

CommandSink is a base class that you should use if, and only if, you want your VM to support RoutedCommands (as described in that article).  In all other situations, use ObservableObject.  In general, you should avoid RoutedCommands (they are known to have perf issues) and stick with something like RelayCommand.

If you're looking for more, and deeper, info about MVVM, I suggest you check out my book 'Advanced MVVM'.