Laurent Bugnion Senior User Experience Integrator IdentityMine
A weird acronym Model – View – ViewModel « MVVM in a SLOOB with SLUT » Woven into WPF/SL Some confusion: MVVM is really just the pattern The rest are helpers, practices, etc
ModelView Controller
ModelView Controller
ModelView Presentation Model (ViewModel) DataBinding
Testability, Maintainability, Blendability “The ability to be edited in Blend” (and Visual Studio designer…) Differentiate code in design and runtime Create design time data
Hello MVVM (and Hi Blend)
View ViewModel DataBindingCommandsMessages Model
View ViewModel View ViewModel View ViewModel Messages + callback
“Point of entry” for a method Can be data bound ICommand interface Execute method CanExecute method CanExecuteChanged event
Should be simple by default Possible to open filtered channels To a target Type (or an Interface) With a Token No constraints at all
Commands and RelayCommands, Messaging
“Breaking the monotony” V3 SP1 released with phone support Keep it small Keep it simple
ESSENTIALS RelayCommand Messenger ViewModelBase EXTRAS EventToCommand DispatcherHelper
Project templates (VS + Blend) Item templates (VS + Blend) Code snippets
MVVM Light, Unity, Blendability
Too much code needed INotifyPropertyChanged Commands Some operations are tricky (set focus…) Not applicable to ASP.NET, etc Message to community is not clear
“No code in the code behind” “If you put code in the View's code-behind, the MVVM police will take your family away” “No need for converters” “MVVM is only suitable for big projects” “MVVM costs performance” “MVVM is complex / makes my head hurt”
“I don’t need separation because I don’t have a designer” “You cannot use MVVM with other patterns” “MVVM will make you rich and attractive”