MVVM with WPF

3,590 views

Published on

Presentation on what and how of MVVM design pattern usage in Windows Presentation Foundation.

Published in: Technology
2 Comments
0 Likes
Statistics
Notes
  • Hi,

    Here is the link of implementation of MVVM pattern in WPF with Example
    http://wpftutorial.co/WPF-MVVM-Patern

    Thanks
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Here is nice code example of MVVM for WPF: http://www.codearsenal.net/2012/05/mvvm.html
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

No Downloads
Views
Total views
3,590
On SlideShare
0
From Embeds
0
Number of Embeds
22
Actions
Shares
0
Downloads
60
Comments
2
Likes
0
Embeds 0
No embeds

No notes for slide

MVVM with WPF

  1. 1. M-V-VMModel View ViewModel for WPF (Design Pattern)
  2. 2. HighlightsCreated By John Gossman (WPF and SilverlightArchitect at Microsoft)This pattern is a simple and effective set of Guidelinesfor Designing and Implementing a WPF applicationAllows you to create a strong separation betweendata, behavior and presentation (UI)
  3. 3. UsesDatabinding for 2 way communication between View (UI) and ViewModel Uses Command pattern (ICommand interface) forcommunicating actions or events that happen on View (UI) Dependency Properties alongwith Data Binding tocommunicate data changes to and from the View (UI)
  4. 4. WPF MVVM Application Layers
  5. 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. 6. AdvantagesViewModel classes are easy to unit test the complete UI without touching the UI codeTesting through ViewModel provides free and fast regression testing which helps toreduce cost of maintaining application over timeHelps 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 fileTakes full advantage of WPF’s Data Templates and CommandsGives more flexibility to change UI without having to refactor the logic or change othercode base
  7. 7. What do u need to Understand in Order to Learn and Implement MVVMData Binding in WPF • http://msdn.microsoft.com/magazine/cc700358Command 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/cc785480Composite Application Library from Microsoft • http://msdn.microsoft.com/library/cc707890For Unit Testing: • Nunit • Moq Framework for .Net (Third Party classes for testing .Net Apps)
  8. 8. References and ResourcesWPF Model-View-ViewModel Toolkit•http://wpf.codeplex.com/wikipage?title=WPF%20Model-View-ViewModel%20ToolkitMVVM 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.htmlMVVM MSDN Article:•http://msdn.microsoft.com/en-us/magazine/dd419663.aspxMVVM 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. 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

×