USING THE MODEL VIEWMODEL PATTERN Laurent Bugnion Director

USING THE MODEL -VIEWMODEL PATTERN Laurent Bugnion Director, User Experience Integration Identity. Mine http: //[blog|www]. galasoft. ch

WHAT IS MVVM? • A weird acronym – Model – View. Model • Woven into WPF / Silverlight / WP 7 • Some confusion: – MVVM is really just the pattern – The rest are helpers, practices, etc © 2011 Identity. Mine Inc. All Rights Reserved. Page: 2

THE MVC PATTERN Model View Controller © 2011 Identity. Mine Inc. All Rights Reserved. Page: 3

THE PASSIVE VIEW PATTERN Model View Controller © 2011 Identity. Mine Inc. All Rights Reserved. Page: 4

THE PRESENTATION MODEL PATTERN Model View Data. Binding Presentation Model (View. Model) © 2011 Identity. Mine Inc. All Rights Reserved. Page: 5

ADVANTAGES • Testability, Maintainability, Blendability • “The ability to be edited in Blend” – (and Visual Studio designer…) • Differentiate code in design and runtime • Create design time data © 2011 Identity. Mine Inc. All Rights Reserved. Page: 6

DEMO Hello MVVM (and Hi Blend) © 2011 Identity. Mine Inc. All Rights Reserved. Page: 7

BRIDGING THE GAP View Data. Binding Commands Messages View. Model © 2011 Identity. Mine Inc. All Rights Reserved. Page: 8

BRIDGING THE GAP View Messages View. Model View Messages + callback View. Model © 2011 Identity. Mine Inc. All Rights Reserved. Page: 9

COMMANDS • “Point of entry” for a method • Can be data bound • ICommand interface – Execute method – Can. Execute. Changed event • Not available in WP 7 – (but there are ways around that ; ) © 2011 Identity. Mine Inc. All Rights Reserved. Page: 10

DEMO • Commands and Relay. Commands • Messaging © 2011 Identity. Mine Inc. All Rights Reserved. Page: 11

MVVM LIGHT TOOLKIT • • • “Breaking the monotony” http: //www. galasoft. ch/mvvm/ http: //mvvmlight. codeplex. com V 3 released at MIX 10 Keep it small Keep it simple © 2011 Identity. Mine Inc. All Rights Reserved. Page: 12

CALIBURN / MICRO • • Rob Eisenberg Convention over configuration http: //caliburn. codeplex. com Also available for Windows Phone 7 – Caliburn. Micro © 2011 Identity. Mine Inc. All Rights Reserved. Page: 13

FLAWS OF MVVM • Too much code needed – INotify. Property. Changed – Commands • Some operations are tricky (set focus, navigation…) • Not really applicable to ASP. NET, etc © 2011 Identity. Mine Inc. All Rights Reserved. Page: 14

FURTHER INFORMATION http: //www. galasoft. ch/mvvmvideo 1 http: //blog. galasoft. ch http: //www. galasoft. ch/mvvm @LBugnion

THANKS!
- Slides: 16