16. • MVVM was designed to make use of data
binding functions in WPF to better
facilitate the separation of view layer
development from the rest of the pattern
by removing virtually all GUI code (“code-
behind”) from the view layer.
17.
18.
19.
20. What's MVVM?
• is an architectural pattern created by
John Gossman from WPF team
• is a variation of MVC pattern
• is similar to Martin Fowler’s
PresentationModel pattern
• WPF Data Binding & Commanding
21. Motivation and benefits
• Testabiltiy ( ViewModel is easier to unit test than
code-behind or event driven code)
• Clear seperation between UX designer and
developer
• Increases the "Blendability" of your view
• Model never needs to be changed to support
changes to the view
• ViewModel rarely needs to be changed to
support changes to the view
• No duplicated code to update views
22. MVVM
• View knows ViewModel
• ViewModel knows Models
• But not vice versa.
View ViewModel Model
23. View
• represents the user interface that the user
will see.
• can be a user control or Data Template
• shouldn't contain any logic that you want
to test
• Keep the view as simple as possible.
24. View Model
• An abstraction of View
• Connector between View and Model
• Keep View State, Value Conversion
• No strong or weak (via Interface) reference
of View
• Make VM as testable as possible (e.g. no
call to Singleton class)
• No Control related Stuff in VM
25. Model
• can be Data Model, DTO, POCO, auto-
generated proxy of domain class and UI
Model based on how you want to have the
separation between Domain Service and
Presentation Layer
• No reference to ViewModel