SlideShare a Scribd company logo
1 of 9
M-V-VM

Model View ViewModel for WPF
       (Design Pattern)
Highlights

Created By John Gossman (WPF and Silverlight
Architect at Microsoft)

This pattern is a simple and effective set of Guidelines
for Designing and Implementing a WPF application

Allows you to create a strong separation between
data, behavior and presentation (UI)
Uses

Databinding for 2 way communication between View
                (UI) and ViewModel

  Uses Command pattern (ICommand interface) for
communicating actions or events that happen on View
                       (UI)

  Dependency Properties alongwith Data Binding to
communicate data changes to and from the View (UI)
WPF MVVM Application Layers
What is View, Model and ViewModel?

View                               ViewModel                          Model
• represents the UI that the end   • is the abstraction of the View   • Represents the data classes
  user sees                          (UI)                               and contains the data, bound
• can be a user control or Data    • Communicates data                  to view and modified by view
  Template                           modifications to the Model       • Hold only the data or
• shouldn’t contain any logic or     from the View                      information related to an
  code that is to be tested        • Data changes in Model are          Object;
                                     reflected in the View through    • It doesn’t contain the
                                     ViewModel by making use of         behaviors or services that
                                     data Binding and dependency        manipulate this data or
                                     properties                         information, though
                                                                        sometimes it may contain data        View knows
                                                                        validation logic                                                                  Multiple Views : 1
                                                                                                        ViewModel, ViewModel
                                                                      • Example is “The Contact                                 1 View : 1 ViewModel   ViewModel (for Wizard
                                                                        information of a person” like    knows Model, but not
                                                                                                                                                        kind of applications)
                                                                        Name, Phone                           vice versa
                                                                        No, Email, Address, Zip Code
                                                                        etc.
Advantages
ViewModel classes are easy to unit test the complete UI without touching the UI code

Testing through ViewModel provides free and fast regression testing which helps to
reduce cost of maintaining application over time

Helps create a smooth Designer/developer workflow

 • Design team can focus on creating user-friendly views while,
 • Development team can focus on creating robust ViewModel classes
 • Which can then be integrated to ensure proper data bindings exist in the View’s XAML file

Takes full advantage of WPF’s Data Templates and Commands

Gives more flexibility to change UI without having to refactor the logic or change other
code base
What do u need to Understand in
 Order to Learn and Implement MVVM
Data Binding in WPF
  • http://msdn.microsoft.com/magazine/cc700358

Command Pattern Implementation in WPF
  • ICommand Interface usage
       public interface Icommand
       {
         bool CanExecute(object param);
         void Execute(object param);
         event EventHandler CanExecuteChanged;
       }

  • RelayCommand pattern
  • Routed Events and Commands in WPF
    • http://msdn.microsoft.com/magazine/cc785480

Composite Application Library from Microsoft
  • http://msdn.microsoft.com/library/cc707890

For Unit Testing:
  • Nunit
  • Moq Framework for .Net (Third Party classes for testing .Net Apps)
References and Resources
WPF Model-View-ViewModel Toolkit

•http://wpf.codeplex.com/wikipage?title=WPF%20Model-View-ViewModel%20Toolkit

MVVM Foundation on codeplex (A set of classes that helps build WPF Apps based on MVVM)

•http://mvvmfoundation.codeplex.com/

Super Simple MVVM Explained video:

•http://www.charlieblog.net/SuperSimpleMVVM/Large/SuperSimple_MVVM_large/SuperSimple_MVVM_large.html

MVVM MSDN Article:

•http://msdn.microsoft.com/en-us/magazine/dd419663.aspx

MVVM Channel9 video with Karl Shifflett

•http://channel9.msdn.com/shows/Continuum/MVVM/

WPF MVVM Video by Jason Dolinger

•http://hugeonion.com/2009/03/08/wpf-mvvm-video-by-jason-dolinger/

MVVM Explained

•http://csharperimage.jeremylikness.com/2010/04/model-view-viewmodel-mvvm-explained.html
Last Note on MVVM
• It is said that if you have not given names for
  your UI Elements and still able to run and
  process the application properly, the MVVM
  Implementation is clean, complete and proper



  – THANKS

More Related Content

What's hot

iOS architecture patterns
iOS architecture patternsiOS architecture patterns
iOS architecture patternsallanh0526
 
What are Microservices | Microservices Architecture Training | Microservices ...
What are Microservices | Microservices Architecture Training | Microservices ...What are Microservices | Microservices Architecture Training | Microservices ...
What are Microservices | Microservices Architecture Training | Microservices ...Edureka!
 
[Android] Widget Event Handling
[Android] Widget Event Handling[Android] Widget Event Handling
[Android] Widget Event HandlingNikmesoft Ltd
 
InjectionIII의 Hot Reload를 이용하여 앱 개발을 좀 더 편하게 하기.pdf
InjectionIII의 Hot Reload를 이용하여 앱 개발을 좀 더 편하게 하기.pdfInjectionIII의 Hot Reload를 이용하여 앱 개발을 좀 더 편하게 하기.pdf
InjectionIII의 Hot Reload를 이용하여 앱 개발을 좀 더 편하게 하기.pdf정민 안
 
An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.jsPagepro
 
Tp3 - Application SOA avec BPEL
Tp3 - Application SOA avec BPELTp3 - Application SOA avec BPEL
Tp3 - Application SOA avec BPELLilia Sfaxi
 
Using hilt in a modularized project
Using hilt in a modularized projectUsing hilt in a modularized project
Using hilt in a modularized projectFabio Collini
 
Designing APIs with OpenAPI Spec
Designing APIs with OpenAPI SpecDesigning APIs with OpenAPI Spec
Designing APIs with OpenAPI SpecAdam Paxton
 
Swift in SwiftUI
Swift in SwiftUISwift in SwiftUI
Swift in SwiftUIBongwon Lee
 
How to create a User Defined Policy with IBM APIc (v10)
How to create a User Defined Policy with IBM APIc (v10)How to create a User Defined Policy with IBM APIc (v10)
How to create a User Defined Policy with IBM APIc (v10)Shiu-Fun Poon
 
Technologies sur angular.pptx
Technologies sur angular.pptxTechnologies sur angular.pptx
Technologies sur angular.pptxIdrissaDembl
 
Asp.net mvc basic introduction
Asp.net mvc basic introductionAsp.net mvc basic introduction
Asp.net mvc basic introductionBhagath Gopinath
 

What's hot (20)

iOS architecture patterns
iOS architecture patternsiOS architecture patterns
iOS architecture patterns
 
Svelte JS introduction
Svelte JS introductionSvelte JS introduction
Svelte JS introduction
 
MVVM
MVVMMVVM
MVVM
 
What are Microservices | Microservices Architecture Training | Microservices ...
What are Microservices | Microservices Architecture Training | Microservices ...What are Microservices | Microservices Architecture Training | Microservices ...
What are Microservices | Microservices Architecture Training | Microservices ...
 
WCF
WCFWCF
WCF
 
[Android] Widget Event Handling
[Android] Widget Event Handling[Android] Widget Event Handling
[Android] Widget Event Handling
 
InjectionIII의 Hot Reload를 이용하여 앱 개발을 좀 더 편하게 하기.pdf
InjectionIII의 Hot Reload를 이용하여 앱 개발을 좀 더 편하게 하기.pdfInjectionIII의 Hot Reload를 이용하여 앱 개발을 좀 더 편하게 하기.pdf
InjectionIII의 Hot Reload를 이용하여 앱 개발을 좀 더 편하게 하기.pdf
 
MVVM & RxSwift
MVVM & RxSwiftMVVM & RxSwift
MVVM & RxSwift
 
An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.js
 
Tp3 - Application SOA avec BPEL
Tp3 - Application SOA avec BPELTp3 - Application SOA avec BPEL
Tp3 - Application SOA avec BPEL
 
Using hilt in a modularized project
Using hilt in a modularized projectUsing hilt in a modularized project
Using hilt in a modularized project
 
Designing APIs with OpenAPI Spec
Designing APIs with OpenAPI SpecDesigning APIs with OpenAPI Spec
Designing APIs with OpenAPI Spec
 
Doing REST Right
Doing REST RightDoing REST Right
Doing REST Right
 
Swift in SwiftUI
Swift in SwiftUISwift in SwiftUI
Swift in SwiftUI
 
Fluent validation
Fluent validationFluent validation
Fluent validation
 
How to create a User Defined Policy with IBM APIc (v10)
How to create a User Defined Policy with IBM APIc (v10)How to create a User Defined Policy with IBM APIc (v10)
How to create a User Defined Policy with IBM APIc (v10)
 
Svelte
SvelteSvelte
Svelte
 
Technologies sur angular.pptx
Technologies sur angular.pptxTechnologies sur angular.pptx
Technologies sur angular.pptx
 
Asp.net mvc basic introduction
Asp.net mvc basic introductionAsp.net mvc basic introduction
Asp.net mvc basic introduction
 
Mvc, mvp, mvvm...
Mvc, mvp, mvvm...Mvc, mvp, mvvm...
Mvc, mvp, mvvm...
 

Similar to MVVM with WPF

Introduction To MVVM
Introduction To MVVMIntroduction To MVVM
Introduction To MVVMBoulos Dib
 
Architectural Design & Patterns
Architectural Design&PatternsArchitectural Design&Patterns
Architectural Design & PatternsInocentshuja Ahmad
 
Mvc pattern and implementation in java fair
Mvc   pattern   and implementation   in   java fairMvc   pattern   and implementation   in   java fair
Mvc pattern and implementation in java fairTech_MX
 
Web engineering - MVC
Web engineering - MVCWeb engineering - MVC
Web engineering - MVCNosheen Qamar
 
Using mvvm inside mvc in domain driven design
Using mvvm inside mvc in domain driven designUsing mvvm inside mvc in domain driven design
Using mvvm inside mvc in domain driven designyashar Aliabasi
 
GUI patterns : My understanding
GUI patterns : My understandingGUI patterns : My understanding
GUI patterns : My understandingNitin Bhide
 
Models used in iOS programming, with a focus on MVVM
Models used in iOS programming, with a focus on MVVMModels used in iOS programming, with a focus on MVVM
Models used in iOS programming, with a focus on MVVMAndrei Popa
 
WPF For Beginners - Learn in 3 days
WPF For Beginners  - Learn in 3 daysWPF For Beginners  - Learn in 3 days
WPF For Beginners - Learn in 3 daysUdaya Kumar
 
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOSSoftware architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOSJinkyu Kim
 
Mvvm in the real world tccc10
Mvvm in the real world   tccc10Mvvm in the real world   tccc10
Mvvm in the real world tccc10Bryan Anderson
 
SUE AGILE MVVM (English)
SUE AGILE MVVM (English)SUE AGILE MVVM (English)
SUE AGILE MVVM (English)Sabino Labarile
 
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesMobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesQamar Abbas
 

Similar to MVVM with WPF (20)

MVVM Presentation
MVVM PresentationMVVM Presentation
MVVM Presentation
 
Introduction To MVVM
Introduction To MVVMIntroduction To MVVM
Introduction To MVVM
 
Architectural Design & Patterns
Architectural Design&PatternsArchitectural Design&Patterns
Architectural Design & Patterns
 
MVVM and Prism
MVVM and PrismMVVM and Prism
MVVM and Prism
 
Knockout js
Knockout jsKnockout js
Knockout js
 
Mvc pattern and implementation in java fair
Mvc   pattern   and implementation   in   java fairMvc   pattern   and implementation   in   java fair
Mvc pattern and implementation in java fair
 
MVC
MVCMVC
MVC
 
Adopting MVVM
Adopting MVVMAdopting MVVM
Adopting MVVM
 
MVP Clean Architecture
MVP Clean  Architecture MVP Clean  Architecture
MVP Clean Architecture
 
Web engineering - MVC
Web engineering - MVCWeb engineering - MVC
Web engineering - MVC
 
Using mvvm inside mvc in domain driven design
Using mvvm inside mvc in domain driven designUsing mvvm inside mvc in domain driven design
Using mvvm inside mvc in domain driven design
 
MVC
MVCMVC
MVC
 
GUI patterns : My understanding
GUI patterns : My understandingGUI patterns : My understanding
GUI patterns : My understanding
 
Models used in iOS programming, with a focus on MVVM
Models used in iOS programming, with a focus on MVVMModels used in iOS programming, with a focus on MVVM
Models used in iOS programming, with a focus on MVVM
 
Mvc, mvp & mvvm (erp)
Mvc, mvp & mvvm (erp)Mvc, mvp & mvvm (erp)
Mvc, mvp & mvvm (erp)
 
WPF For Beginners - Learn in 3 days
WPF For Beginners  - Learn in 3 daysWPF For Beginners  - Learn in 3 days
WPF For Beginners - Learn in 3 days
 
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOSSoftware architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
 
Mvvm in the real world tccc10
Mvvm in the real world   tccc10Mvvm in the real world   tccc10
Mvvm in the real world tccc10
 
SUE AGILE MVVM (English)
SUE AGILE MVVM (English)SUE AGILE MVVM (English)
SUE AGILE MVVM (English)
 
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesMobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelines
 

Recently uploaded

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 

Recently uploaded (20)

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

MVVM with WPF

  • 1. M-V-VM Model View ViewModel for WPF (Design Pattern)
  • 2. Highlights Created By John Gossman (WPF and Silverlight Architect at Microsoft) This pattern is a simple and effective set of Guidelines for Designing and Implementing a WPF application Allows you to create a strong separation between data, behavior and presentation (UI)
  • 3. Uses Databinding for 2 way communication between View (UI) and ViewModel Uses Command pattern (ICommand interface) for communicating actions or events that happen on View (UI) Dependency Properties alongwith Data Binding to communicate data changes to and from the View (UI)
  • 5. What is View, Model and ViewModel? View ViewModel Model • represents the UI that the end • is the abstraction of the View • Represents the data classes user sees (UI) and contains the data, bound • can be a user control or Data • Communicates data to view and modified by view Template modifications to the Model • Hold only the data or • shouldn’t contain any logic or from the View information related to an code that is to be tested • Data changes in Model are Object; reflected in the View through • It doesn’t contain the ViewModel by making use of behaviors or services that data Binding and dependency manipulate this data or properties information, though sometimes it may contain data View knows validation logic Multiple Views : 1 ViewModel, ViewModel • Example is “The Contact 1 View : 1 ViewModel ViewModel (for Wizard information of a person” like knows Model, but not kind of applications) Name, Phone vice versa No, Email, Address, Zip Code etc.
  • 6. Advantages ViewModel classes are easy to unit test the complete UI without touching the UI code Testing through ViewModel provides free and fast regression testing which helps to reduce cost of maintaining application over time Helps create a smooth Designer/developer workflow • Design team can focus on creating user-friendly views while, • Development team can focus on creating robust ViewModel classes • Which can then be integrated to ensure proper data bindings exist in the View’s XAML file Takes full advantage of WPF’s Data Templates and Commands Gives more flexibility to change UI without having to refactor the logic or change other code base
  • 7. What do u need to Understand in Order to Learn and Implement MVVM Data Binding in WPF • http://msdn.microsoft.com/magazine/cc700358 Command Pattern Implementation in WPF • ICommand Interface usage public interface Icommand { bool CanExecute(object param); void Execute(object param); event EventHandler CanExecuteChanged; } • RelayCommand pattern • Routed Events and Commands in WPF • http://msdn.microsoft.com/magazine/cc785480 Composite Application Library from Microsoft • http://msdn.microsoft.com/library/cc707890 For Unit Testing: • Nunit • Moq Framework for .Net (Third Party classes for testing .Net Apps)
  • 8. References and Resources WPF Model-View-ViewModel Toolkit •http://wpf.codeplex.com/wikipage?title=WPF%20Model-View-ViewModel%20Toolkit MVVM Foundation on codeplex (A set of classes that helps build WPF Apps based on MVVM) •http://mvvmfoundation.codeplex.com/ Super Simple MVVM Explained video: •http://www.charlieblog.net/SuperSimpleMVVM/Large/SuperSimple_MVVM_large/SuperSimple_MVVM_large.html MVVM MSDN Article: •http://msdn.microsoft.com/en-us/magazine/dd419663.aspx MVVM Channel9 video with Karl Shifflett •http://channel9.msdn.com/shows/Continuum/MVVM/ WPF MVVM Video by Jason Dolinger •http://hugeonion.com/2009/03/08/wpf-mvvm-video-by-jason-dolinger/ MVVM Explained •http://csharperimage.jeremylikness.com/2010/04/model-view-viewmodel-mvvm-explained.html
  • 9. Last Note on MVVM • It is said that if you have not given names for your UI Elements and still able to run and process the application properly, the MVVM Implementation is clean, complete and proper – THANKS