SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Understanding the
MVVM pattern
Laurent Bugnion
Senior User Experience Integrator
IdentityMine
http://[blog|www].galasoft.ch
What is MVVM?

 • A weird acronym
   • Model – View – ViewModel
   • « MVVM in a SLOOB with SLUT »


 • Woven into WPF/SL
 • Some confusion:
   • MVVM is really just the pattern
   • The rest are helpers, practices, etc
The MVC pattern




                  Model                View




                          Controller
The Passive View pattern




                 Model                  View




                           Controller
The Presentation Model pattern




                 Model                  View

                                        DataBinding


                         Presentation
                            Model
                         (ViewModel)
Blendability

  • Testability, Maintainability, Blendability

  • “The ability to be edited in Blend”

     • (and Visual Studio designer…)

  • Differentiate code in design and runtime

  • Create design time data
Hello MVVM (and Hi Blend)
Bridging the gap


                            View


                   DataBinding      Commands   Messages




                             ViewModel




                            Model
Bridging the gap

                                                View


            View
                            Messages       ViewModel


         ViewModel
                                         View

                   Messages
                   + callback

                                       ViewModel
Commands

 • “Point of entry” for a method”

 • Can be data bound

 • ICommand interface

   • Execute method

   • CanExecute method

   • CanExecuteChanged event handler
Commands
and RelayCommands
RelayCommands


  RelayCommand MyCommand
    = new RelayCommand(
      () => ...,
      () => true | false);

  RelayCommand<T> MyGenericCommand
    = new RelayCommand<T>(
      p => ...,
      p => true | false);
Messaging

 • Should be simple by default

 • Possible to open filtered channels

    • To a target Type (or an Interface)

    • With a Token

    • With various Messenger instances

 • No constraints at all
Messaging
Messaging


  Messenger.Default.Register<T>(
      this,
      p => DoSomething(p));

  Messenger.Default.Send<T>(p);
MVVM Light Toolkit

  • “Breaking the monotony”

  • http://www.galasoft.ch/mvvm/getstarted

  • http://mvvmlight.codeplex.com

  • V3 released at MIX10

  • Keep it small
  • Keep it simple
MVVM Light Libraries V3

  • ESSENTIALS
    • RelayCommand
    • Messenger
    • ViewModelBase
  • EXTRAS
    • EventToCommand
    • DispatcherHelper
MVVM Light Tools V3


 • Project templates (VS + Blend)


 • Item templates (VS + Blend)


 • Code snippets
MVVM Light Toolkit,
Unity,
Blendability
Flaws of MVVM

  • Too much code needed
    • INotifyPropertyChanged
    • Commands
  • Some operations are tricky (set focus…)
  • Not applicable to ASP.NET, etc
  • Message to community is not clear
Debunking the myths

  • “No code in the code behind”
    • “If you put code in the View's code-behind, the
     MVVM police will take your family away”
    • “No need for converters”

  • “MVVM is only suitable for big projects”
  • “MVVM costs performance”
  • “MVVM is complex / makes my head hurt”
Debunking the myths

  • “I don’t need separation because I don’t
   have a designer”
  • “You cannot use MVVM with other
   patterns”
  • “MVVM will make you rich and attractive”
MVVM on the
Windows Phone 7
http://blog.galasoft.ch
http://www.galasoft.ch/mvvm/getstarted
@LBugnion

Weitere ähnliche Inhalte

Was ist angesagt?

MVVM with WPF
MVVM with WPFMVVM with WPF
MVVM with WPFS V
 
Learn skills technologies
Learn skills technologiesLearn skills technologies
Learn skills technologiess_shankar1977
 
Migrating MVVM Applications to HTML5
Migrating MVVM Applications to HTML5Migrating MVVM Applications to HTML5
Migrating MVVM Applications to HTML5Chris Bannon
 
[Mas 500] Web Basics
[Mas 500] Web Basics[Mas 500] Web Basics
[Mas 500] Web Basicsrahulbot
 
JavaScript Framework Smackdown
JavaScript Framework SmackdownJavaScript Framework Smackdown
JavaScript Framework Smackdownmeghantaylor
 
MVVM Light Toolkit Works Great, Less Complicated
MVVM Light ToolkitWorks Great, Less ComplicatedMVVM Light ToolkitWorks Great, Less Complicated
MVVM Light Toolkit Works Great, Less Complicatedmdc11
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 2...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 2... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 2...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 2...WebStackAcademy
 
A Smooth Transition to HTML5 Using MVVM
A Smooth Transition to HTML5 Using MVVMA Smooth Transition to HTML5 Using MVVM
A Smooth Transition to HTML5 Using MVVMChris Bannon
 
Gemeinsame View-Models mit XAML Technologien
Gemeinsame View-Models mit XAML TechnologienGemeinsame View-Models mit XAML Technologien
Gemeinsame View-Models mit XAML TechnologienChristian Nagel
 
MVVM Windows UWP apps with Template 10
MVVM Windows UWP apps with Template 10MVVM Windows UWP apps with Template 10
MVVM Windows UWP apps with Template 10Jiri Danihelka
 
Javascript(2)
Javascript(2)Javascript(2)
Javascript(2)tomcoh
 
A Good PHP Framework For Beginners Like Me!
A Good PHP Framework For Beginners Like Me!A Good PHP Framework For Beginners Like Me!
A Good PHP Framework For Beginners Like Me!Muhammad Ghazali
 

Was ist angesagt? (18)

MVVM with WPF
MVVM with WPFMVVM with WPF
MVVM with WPF
 
Training: MVVM Pattern
Training: MVVM PatternTraining: MVVM Pattern
Training: MVVM Pattern
 
XAML/C# to HTML5/JS
XAML/C#  to HTML5/JS XAML/C#  to HTML5/JS
XAML/C# to HTML5/JS
 
Learn skills technologies
Learn skills technologiesLearn skills technologies
Learn skills technologies
 
Migrating MVVM Applications to HTML5
Migrating MVVM Applications to HTML5Migrating MVVM Applications to HTML5
Migrating MVVM Applications to HTML5
 
Introduction to Umbraco
Introduction to UmbracoIntroduction to Umbraco
Introduction to Umbraco
 
[Mas 500] Web Basics
[Mas 500] Web Basics[Mas 500] Web Basics
[Mas 500] Web Basics
 
JavaScript Framework Smackdown
JavaScript Framework SmackdownJavaScript Framework Smackdown
JavaScript Framework Smackdown
 
MVVM Light Toolkit Works Great, Less Complicated
MVVM Light ToolkitWorks Great, Less ComplicatedMVVM Light ToolkitWorks Great, Less Complicated
MVVM Light Toolkit Works Great, Less Complicated
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 2...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 2... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 2...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 2...
 
MVVM frameworks
MVVM frameworksMVVM frameworks
MVVM frameworks
 
A Smooth Transition to HTML5 Using MVVM
A Smooth Transition to HTML5 Using MVVMA Smooth Transition to HTML5 Using MVVM
A Smooth Transition to HTML5 Using MVVM
 
MVVM with Kendo UI
MVVM with Kendo UIMVVM with Kendo UI
MVVM with Kendo UI
 
Gemeinsame View-Models mit XAML Technologien
Gemeinsame View-Models mit XAML TechnologienGemeinsame View-Models mit XAML Technologien
Gemeinsame View-Models mit XAML Technologien
 
MVVM Windows UWP apps with Template 10
MVVM Windows UWP apps with Template 10MVVM Windows UWP apps with Template 10
MVVM Windows UWP apps with Template 10
 
Beginning In J2EE
Beginning In J2EEBeginning In J2EE
Beginning In J2EE
 
Javascript(2)
Javascript(2)Javascript(2)
Javascript(2)
 
A Good PHP Framework For Beginners Like Me!
A Good PHP Framework For Beginners Like Me!A Good PHP Framework For Beginners Like Me!
A Good PHP Framework For Beginners Like Me!
 

Ähnlich wie Understanding The MVVM Pattern (TechDays Belgium)

Advanced MVVM in Windows 8
Advanced MVVM in Windows 8Advanced MVVM in Windows 8
Advanced MVVM in Windows 8Gill Cleeren
 
MVP Mix 2015 Leveraging MVVM on all Platforms
MVP Mix 2015  Leveraging MVVM on all PlatformsMVP Mix 2015  Leveraging MVVM on all Platforms
MVP Mix 2015 Leveraging MVVM on all PlatformsJames Montemagno
 
An introduction to knockout.js
An introduction to knockout.jsAn introduction to knockout.js
An introduction to knockout.jsEmanuele DelBono
 
JavaScript TDD
JavaScript TDDJavaScript TDD
JavaScript TDDUri Lavi
 
MVVM for Modern Applications
MVVM for Modern ApplicationsMVVM for Modern Applications
MVVM for Modern ApplicationsJeremy Likness
 
Building an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernateBuilding an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernatebwullems
 
Windows Phone App with MVVM design patten
Windows Phone App with MVVM design pattenWindows Phone App with MVVM design patten
Windows Phone App with MVVM design pattenKamalakannan Annamalai
 
Prism library and MVVM
Prism library and MVVMPrism library and MVVM
Prism library and MVVMJiri Danihelka
 
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
 
Modern ASP.NET Webskills
Modern ASP.NET WebskillsModern ASP.NET Webskills
Modern ASP.NET WebskillsCaleb Jenkins
 
jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture Jiby John
 
MVVM in iOS presentation
MVVM in iOS presentationMVVM in iOS presentation
MVVM in iOS presentationG ABHISEK
 
Model View Madness
Model View MadnessModel View Madness
Model View MadnessMike Wilcox
 
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesMobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesQamar Abbas
 
Building databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with KnockoutjsBuilding databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with KnockoutjsNish Anil
 
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCross
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCrossC# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCross
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCrossFlavius-Radu Demian
 
Sugarcoating your frontend one ViewModel at a time
Sugarcoating your frontend one ViewModel at a timeSugarcoating your frontend one ViewModel at a time
Sugarcoating your frontend one ViewModel at a timeEinar Ingebrigtsen
 

Ähnlich wie Understanding The MVVM Pattern (TechDays Belgium) (20)

Advanced MVVM in Windows 8
Advanced MVVM in Windows 8Advanced MVVM in Windows 8
Advanced MVVM in Windows 8
 
MVP Mix 2015 Leveraging MVVM on all Platforms
MVP Mix 2015  Leveraging MVVM on all PlatformsMVP Mix 2015  Leveraging MVVM on all Platforms
MVP Mix 2015 Leveraging MVVM on all Platforms
 
MVVM and Prism
MVVM and PrismMVVM and Prism
MVVM and Prism
 
Adopting MVVM
Adopting MVVMAdopting MVVM
Adopting MVVM
 
An introduction to knockout.js
An introduction to knockout.jsAn introduction to knockout.js
An introduction to knockout.js
 
JavaScript TDD
JavaScript TDDJavaScript TDD
JavaScript TDD
 
MVVM for Modern Applications
MVVM for Modern ApplicationsMVVM for Modern Applications
MVVM for Modern Applications
 
Building an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernateBuilding an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernate
 
Windows Phone App with MVVM design patten
Windows Phone App with MVVM design pattenWindows Phone App with MVVM design patten
Windows Phone App with MVVM design patten
 
Prism library and MVVM
Prism library and MVVMPrism library and MVVM
Prism library and MVVM
 
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
 
Modern ASP.NET Webskills
Modern ASP.NET WebskillsModern ASP.NET Webskills
Modern ASP.NET Webskills
 
Applied MVVM in Windows 8 apps: not your typical MVVM session!
Applied MVVM in Windows 8 apps: not your typical MVVM session!Applied MVVM in Windows 8 apps: not your typical MVVM session!
Applied MVVM in Windows 8 apps: not your typical MVVM session!
 
jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture
 
MVVM in iOS presentation
MVVM in iOS presentationMVVM in iOS presentation
MVVM in iOS presentation
 
Model View Madness
Model View MadnessModel View Madness
Model View Madness
 
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesMobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelines
 
Building databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with KnockoutjsBuilding databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with Knockoutjs
 
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCross
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCrossC# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCross
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCross
 
Sugarcoating your frontend one ViewModel at a time
Sugarcoating your frontend one ViewModel at a timeSugarcoating your frontend one ViewModel at a time
Sugarcoating your frontend one ViewModel at a time
 

Kürzlich hochgeladen

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
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
 

Kürzlich hochgeladen (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.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)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 

Understanding The MVVM Pattern (TechDays Belgium)

  • 1.
  • 2. Understanding the MVVM pattern Laurent Bugnion Senior User Experience Integrator IdentityMine http://[blog|www].galasoft.ch
  • 3. What is MVVM? • A weird acronym • Model – View – ViewModel • « MVVM in a SLOOB with SLUT » • Woven into WPF/SL • Some confusion: • MVVM is really just the pattern • The rest are helpers, practices, etc
  • 4. The MVC pattern Model View Controller
  • 5. The Passive View pattern Model View Controller
  • 6. The Presentation Model pattern Model View DataBinding Presentation Model (ViewModel)
  • 7. Blendability • Testability, Maintainability, Blendability • “The ability to be edited in Blend” • (and Visual Studio designer…) • Differentiate code in design and runtime • Create design time data
  • 8. Hello MVVM (and Hi Blend)
  • 9. Bridging the gap View DataBinding Commands Messages ViewModel Model
  • 10. Bridging the gap View View Messages ViewModel ViewModel View Messages + callback ViewModel
  • 11. Commands • “Point of entry” for a method” • Can be data bound • ICommand interface • Execute method • CanExecute method • CanExecuteChanged event handler
  • 13. RelayCommands RelayCommand MyCommand = new RelayCommand( () => ..., () => true | false); RelayCommand<T> MyGenericCommand = new RelayCommand<T>( p => ..., p => true | false);
  • 14. Messaging • Should be simple by default • Possible to open filtered channels • To a target Type (or an Interface) • With a Token • With various Messenger instances • No constraints at all
  • 16. Messaging Messenger.Default.Register<T>( this, p => DoSomething(p)); Messenger.Default.Send<T>(p);
  • 17. MVVM Light Toolkit • “Breaking the monotony” • http://www.galasoft.ch/mvvm/getstarted • http://mvvmlight.codeplex.com • V3 released at MIX10 • Keep it small • Keep it simple
  • 18. MVVM Light Libraries V3 • ESSENTIALS • RelayCommand • Messenger • ViewModelBase • EXTRAS • EventToCommand • DispatcherHelper
  • 19. MVVM Light Tools V3 • Project templates (VS + Blend) • Item templates (VS + Blend) • Code snippets
  • 21. Flaws of MVVM • Too much code needed • INotifyPropertyChanged • Commands • Some operations are tricky (set focus…) • Not applicable to ASP.NET, etc • Message to community is not clear
  • 22. Debunking the myths • “No code in the code behind” • “If you put code in the View's code-behind, the MVVM police will take your family away” • “No need for converters” • “MVVM is only suitable for big projects” • “MVVM costs performance” • “MVVM is complex / makes my head hurt”
  • 23. Debunking the myths • “I don’t need separation because I don’t have a designer” • “You cannot use MVVM with other patterns” • “MVVM will make you rich and attractive”

Hinweis der Redaktion

  1. Demo of connection to WCF service, fails in BlendShow how to attach to processIdentify problemIsInDesignMode
  2. Demo of connection to WCF service, fails in BlendShow how to attach to processIdentify problemIsInDesignMode
  3. Demo of connection to WCF service, fails in BlendShow how to attach to processIdentify problemIsInDesignMode
  4. Demo of connection to WCF service, fails in BlendShow how to attach to processIdentify problemIsInDesignMode
  5. Demo of connection to WCF service, fails in BlendShow how to attach to processIdentify problemIsInDesignMode