0% found this document useful (0 votes)
84 views15 pages

Intro To MVVM: Dareen Alhiyari

This document provides an introduction to the MVVM design pattern. It describes MVVM as separating an application into three main parts: the Model, the View, and the ViewModel. The Model manages the data and business logic. The View displays the user interface. The ViewModel acts as an intermediary between the Model and View, providing the data and handling user input. Benefits of MVVM include loose coupling between components, testable code, and maintainable code. Some common MVVM frameworks are also listed.

Uploaded by

Reziena Inc.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views15 pages

Intro To MVVM: Dareen Alhiyari

This document provides an introduction to the MVVM design pattern. It describes MVVM as separating an application into three main parts: the Model, the View, and the ViewModel. The Model manages the data and business logic. The View displays the user interface. The ViewModel acts as an intermediary between the Model and View, providing the data and handling user input. Benefits of MVVM include loose coupling between components, testable code, and maintainable code. Some common MVVM frameworks are also listed.

Uploaded by

Reziena Inc.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Intro to MVVM

Dareen Alhiyari
Senior Consultant
[email protected]
[email protected]
What is MVVM

• MVVM is a design pattern

• MVVM stands for Model-View-ViewModel


Design Patterns

• Design patterns are a set of guidelines

• Design patterns are Not a set of rules


Model

It is your data or classes that represent


entities in your application. It normally
contains no WPF-specific code.
• Entity
• Service Proxy
• POCO (Plain Old CLR Object)
View

This is the User Interface element visible to


the user. Its DataContext is its ViewModel.
• XAML (WPF)
• XAML with Code Behind (Silverlight)
ViewModel
It contains all the data that needs to be
displayed and procedures to modify the model
at will. The magic about MVVM is that the
ViewModel knows nothing about the View.
• State
• Operations
• Not dependent on the view
MVVM Relations

ViewModel

Commands

Binding

View Model
Loosely Coupled
• The View knows the ViewModel but the ViewModel does
not know the View.
• You can very easily replace the View without affecting the
ViewModel.
• This is very useful in Developer/Designer teams where the
Developer improves the ViewModel and the Designer
enhances the View.
User Interaction

We always have had commands in WPF. MVVM


leverages on this feature. Instead of writing event
handling code for button clicks, we bind the buttons
(or MenuItems) in the View to Commands in the
ViewModel.
Commands
Commands
MVVM vs. MVC (Model-View-Controller)

MVVM MVC
View
View
* *
1
1
ViewModel Controller

Model
Model
Benefits of MVVM

• Loose coupling
• Testable code
• Maintainable code
Some MVVM Frameworks
Check out this handy tool to compare MVVM frameworks: MVVM Comparison Tool - Silverlight

• PRISM (Microsoft) • Core MVVM


• MVVM Light (Laurent Bugnion) • Onyx
• WPF Application Framework • nRoute
• Chinch • MVVM Foundation
• Caliburn Micro • How to build your own MVVM Framework
Thank you!

Dareen Alhiyari
Senior Consultant
[email protected]
[email protected]

You might also like