Presentation Model
-
Upload
alex-miranda -
Category
Technology
-
view
258 -
download
0
Transcript of Presentation Model
![Page 1: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/1.jpg)
Presentation ModelThe First Contact
![Page 2: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/2.jpg)
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…?
![Page 3: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/3.jpg)
Quick Introduction: Presentation Patterns
![Page 4: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/4.jpg)
UI Patterns Comparison
Passive View Supervising Controller Presentation Model
![Page 5: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/5.jpg)
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.
![Page 6: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/6.jpg)
Model – View – ViewModel
Technology specific implementation of the PM Separation of Markup and Code Behaviour of the Application Look and Feel Tool Support
![Page 7: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/7.jpg)
“Once a developer becomes comfortable with WPF and MVVM, it can be difficult to differentiate the two. ”. Josh Smith, MVVM Guru
![Page 8: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/8.jpg)
Why should I care about it?
Order vs. Chaos Technology Choice Loose Coupling Testability (DEMO) Maintainable Code Blendability (DEMO) It is cool
![Page 9: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/9.jpg)
<Disclaimer>
No Solution is Perfect Different Approaches
View-Centric ViewModel Centric
</Disclaimer>
![Page 10: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/10.jpg)
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
![Page 11: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/11.jpg)
XAML
Humble View Plays nicely with Data Binding
capabilities
![Page 12: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/12.jpg)
Data Binding
Binding Expression Binding Direction Binding to Elements Binding to Templates RelativeSource
![Page 13: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/13.jpg)
DEMO
![Page 14: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/14.jpg)
Commands
Delegate Command vs. Relay Command (DEMO) Uses WPF Behaviours capabilities Map Events to Commands (DEMO)
![Page 15: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/15.jpg)
DEMO
![Page 16: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/16.jpg)
Validation
Implemented on ViewModel, not in Model Class
![Page 17: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/17.jpg)
DEMO
![Page 18: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/18.jpg)
Messaging
Uses a light message bus to communicate between components Publish/Subscribe Frameworks (MVVM Light) (DEMO)
![Page 19: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/19.jpg)
DEMO
MVVM Light Toolkit
![Page 20: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/20.jpg)
ViewModel Locator
Repository of ViewModels Uses WPF DataTemplate Capabilities One View per ViewModel MVVM Light
![Page 21: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/21.jpg)
DEMO
MVVM Light Toolkit
![Page 22: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/22.jpg)
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…
![Page 23: Presentation Model](https://reader035.fdocuments.in/reader035/viewer/2022062319/554f72a0b4c905bb178b52dd/html5/thumbnails/23.jpg)
And continues…
Not used only with WPF/Silverlight: ASP.NET MVC Knockout.js Java frameworks (RLY?)
To Far and Beyond… That’s it ;-)