Date post: | 10-May-2015 |
Category: |
Technology |
Upload: | alex-miranda |
View: | 258 times |
Download: | 0 times |
Presentation ModelThe First Contact
Agenda
Quick Introduction Why should I care about it? View Model XAML Data Binding ViewModel Base Commands Validation Data Templates Resource Systems MVVM Framework How do I do…?
Quick Introduction: Presentation Patterns
UI Patterns Comparison
Passive View Supervising Controller Presentation Model
Presentation Model
“Probably the most annoying part of the Presentation Model is the synchronization between Presentation Model and view. It’s simple code to write, but I always like to minimize this kind of boring repetitive code.Ideally some kind of framework could handle this, which I’m hopping will happen some day with technologies like .NET’s data binding.”
Martin Fowler, 2004.
Model – View – ViewModel
Technology specific implementation of the PM Separation of Markup and Code Behaviour of the Application Look and Feel Tool Support
“Once a developer becomes comfortable with WPF and MVVM, it can be difficult to differentiate the two. ”. Josh Smith, MVVM Guru
Why should I care about it?
Order vs. Chaos Technology Choice Loose Coupling Testability (DEMO) Maintainable Code Blendability (DEMO) It is cool
<Disclaimer>
No Solution is Perfect Different Approaches
View-Centric ViewModel Centric
</Disclaimer>
View Model
Separation of Concerns Enables code reuse State + Operations Provides a Bindable Surface Not Dependent on the View Typically One-To-One ViewModel to View
One-To-Many is very common though
XAML
Humble View Plays nicely with Data Binding
capabilities
Data Binding
Binding Expression Binding Direction Binding to Elements Binding to Templates RelativeSource
DEMO
Commands
Delegate Command vs. Relay Command (DEMO) Uses WPF Behaviours capabilities Map Events to Commands (DEMO)
DEMO
Validation
Implemented on ViewModel, not in Model Class
DEMO
Messaging
Uses a light message bus to communicate between components Publish/Subscribe Frameworks (MVVM Light) (DEMO)
DEMO
MVVM Light Toolkit
ViewModel Locator
Repository of ViewModels Uses WPF DataTemplate Capabilities One View per ViewModel MVVM Light
DEMO
MVVM Light Toolkit
Trade-Offs
Agregate Model vs Proxy Property Start animation on the View through ViewModel How to close a window Clean and Shutdown Handle Navigation Add your own topic to be discussed…
And continues…
Not used only with WPF/Silverlight: ASP.NET MVC Knockout.js Java frameworks (RLY?)
To Far and Beyond… That’s it ;-)