Understanding the mvvm pattern
Download
1 / 22

Understanding the MVVM pattern - PowerPoint PPT Presentation


  • 125 Views
  • Uploaded on

Understanding the MVVM pattern. Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch http://www.identitymine.com. What is MVVM?. A weird acronym Model – View – ViewModel « MVVM in a SLOOB with SLUT » Woven into WPF/SL Some confusion:

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Understanding the MVVM pattern' - lily


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Understanding the mvvm pattern
Understanding the MVVM pattern

Laurent Bugnion

Senior User Experience Integrator

IdentityMine

http://[www|blog].galasoft.chhttp://www.identitymine.com


What is mvvm
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
The MVC pattern

Model

View

Controller


The passive view pattern
The Passive View pattern

Model

View

Controller


The presentation model pattern
The Presentation Model pattern

Model

View

DataBinding

Presentation Model

(ViewModel)


Blendability
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


Understanding the mvvm pattern
Demo

Hello MVVM (and Hi Blend)


Bridging the gap
Bridging the gap

View

DataBinding

Commands

Messages

ViewModel

Model


Bridging the gap1
Bridging the gap

View

View

ViewModel

Messages

ViewModel

View

Messages

+ callback

ViewModel


Commands
Commands

“Point of entry” for a method

Can be data bound

ICommand interface

  • Execute method

  • CanExecute method

  • CanExecuteChanged event


Messaging
Messaging

Should be simple by default

Possible to open filtered channels

  • To a target Type (or an Interface)

  • With a Token

    No constraints at all


Understanding the mvvm pattern
Demo

Commands and RelayCommands,

Messaging


Mvvm light toolkit
MVVM Light Toolkit

“Breaking the monotony”

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

http://mvvmlight.codeplex.com

V3 SP1 released with phone support

Keep it small

Keep it simple


Mvvm light toolkit1
MVVM Light Toolkit

ESSENTIALS

  • RelayCommand

  • Messenger

  • ViewModelBase

    EXTRAS

  • EventToCommand

  • DispatcherHelper


Mvvm light toolkit2
MVVM Light Toolkit

Project templates (VS + Blend)

Item templates (VS + Blend)

Code snippets


Understanding the mvvm pattern
Demo

MVVM Light, Unity, Blendability


Flaws of mvvm
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


Debunk the myths
Debunk 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”


Debunk the myths1
Debunk 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”


Further information
Further information

http://blog.galasoft.ch

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

http://tinyurl.com/mvvmexplained

Twitter: @LBugnion