Overview of the MVVM pattern for Silverlight and WPF.

4
MVVM Design Pattern Overview of the MVVM pattern for Silverlight and WPF

Transcript of Overview of the MVVM pattern for Silverlight and WPF.

Page 1: Overview of the MVVM pattern for Silverlight and WPF.

MVVM Design PatternOverview of the MVVM pattern for

Silverlight and WPF

Page 2: Overview of the MVVM pattern for Silverlight and WPF.

What is MVVM?Part of the M-V-* family of separated

presentation patterns (MVC, MVP, etc.)

Stands for “Model-View-ViewModel”

Adaptation of Fowler’s “Presentation Model”

“Linqua Franca” of WPF and Silverlight

Page 3: Overview of the MVVM pattern for Silverlight and WPF.

What’s a “ViewModel”?Is it a “View of the Model”? or …

A “Model of the View”?

I prefer Model of the View, or Model for the View.

The VM is an abstraction of the state (bindings) and behavior (actions/commands) of the View.

Page 4: Overview of the MVVM pattern for Silverlight and WPF.

View Model as State Machine“When I’m constructing a system, I prefer to

think of the VM as a state machine with the View being a visualization of the current state.  The user interacts with the View, causing “messages” (actions/commands/bindings) to be sent to the VM.  The VM receives and delegates or interprets these messages, which may or may not result in state changes and may or may not result in domain model interaction.” – Rob Eisenberg (Caliburn, NHProf)