INTRODUCTION TO WPF
AND MVVM
SIRAR SALIH
.NET CONSULTANT
Windows Presentation Foundation
• Graphical subsystem introduced by Microsoft to render user interfaces, and
allow develop...
Windows Presentation Foundation
• Microsoft PixelSense (Surface 2.0)

19.01.2014

/

4
Windows Presentation Foundation
• Silverlight
– Most functionality is a subset of WPF
• Latest release: WPF 4.5

19.01.201...
Model-View-ViewModel
• Architectural pattern based on Model-View-Controller (MVC)
• Seperation of Concerns
– Data/Domain o...
Model-View-ViewModel
GUI

View

Logic

ViewModel

Domain

Model

19.01.2014

/

7
WPF + MVVM

How about we combine them? That’s awesome! 

19.01.2014

/

8
Combining WPF and MVVM
View
Commands

DataBinding

ViewModel

Model

19.01.2014

/

9
DataBinding
• Establishes connection between Views and ViewModels
• Enables the View to bind to properties in the ViewMode...
Commands
• Enable the View to call methods in the ViewModel
• Exposed as properties from the ViewModel
• Implement IComman...
MVVM frameworks for WPF
Cocktail
Carbon MVVM

Caliburn
Xomega

MVVM Cross

MVVM foundation

Onyx

MVVM Light Toolkit
Cinch...
MVVM Light Toolkit
•
•
•
•
•
•
•

By Laurent Bugnion
Small and simple
Breaking the monotony
Essentials library
Extras libr...
ViewModelBase
• Utility class that ViewModel inherits from
• Eliminates code duplication
• Introduces the RaisePropertyCha...
EventToCommand
• Enables the passing of arguments to the ViewModel through the Command
• Interaction triggers are used on ...
RelayCommand
• An alternative to Command and RoutedCommand in WPF
• Also implements ICommand
• Relays Execute to own defin...
Messaging
• Easier communication between ViewModels
• Uses Publish-Subscribe pattern
• A receiver ViewModel registeres on ...
Messaging
View

View
Messages

ViewModel

ViewModel
View
Messages

ViewModel
19.01.2014 /

18
Messaging
• Message:

• Sender:

• Receiver:

19.01.2014 /

19
DispatcherHelper
• Useful when working on multi-threaded WPF applications
• Enables the calling of a method on the UI thre...
Live demo

19.01.2014 /

21
Future of WPF
• Windows RT
– No support
• Windows 8 Desktop
– Works
• XAML usage in Windows 8 Store apps

19.01.2014 /

22
QUESTIONS?
THANK YOU

19.01.2014 /

23
Introduction to WPF and MVVM
Introduction to WPF and MVVM
Upcoming SlideShare
Loading in...5
×

Introduction to WPF and MVVM

757

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
757
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
31
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Introduction to WPF and MVVM"

  1. 1. INTRODUCTION TO WPF AND MVVM SIRAR SALIH .NET CONSULTANT
  2. 2. Windows Presentation Foundation • Graphical subsystem introduced by Microsoft to render user interfaces, and allow development of rich, interactive client applications • Was initially known as «Avalon» and first released in .NET 3.0 • Uses DirectX • 2D/3D rendering, vector graphics, animation etc. • Attempts to seperate UI from logic – XAML • Deployment – Standalone desktop client – Can also be embedded in web 19.01.2014 / 3
  3. 3. Windows Presentation Foundation • Microsoft PixelSense (Surface 2.0) 19.01.2014 / 4
  4. 4. Windows Presentation Foundation • Silverlight – Most functionality is a subset of WPF • Latest release: WPF 4.5 19.01.2014 / 5
  5. 5. Model-View-ViewModel • Architectural pattern based on Model-View-Controller (MVC) • Seperation of Concerns – Data/Domain objects (Model), GUI (View), logic (ViewModel) • Eliminates «code-behind» • The beauty of it: Designers can work indepedently on the views and UX, while developers work on the back-end • Allows [easier]: – Maintainability – Testability – Blendability 19.01.2014 / 6
  6. 6. Model-View-ViewModel GUI View Logic ViewModel Domain Model 19.01.2014 / 7
  7. 7. WPF + MVVM How about we combine them? That’s awesome!  19.01.2014 / 8
  8. 8. Combining WPF and MVVM View Commands DataBinding ViewModel Model 19.01.2014 / 9
  9. 9. DataBinding • Establishes connection between Views and ViewModels • Enables the View to bind to properties in the ViewModel • DataContext • Two-way binding • Dependency properties 19.01.2014 / 10
  10. 10. Commands • Enable the View to call methods in the ViewModel • Exposed as properties from the ViewModel • Implement ICommand 19.01.2014 / 11
  11. 11. MVVM frameworks for WPF Cocktail Carbon MVVM Caliburn Xomega MVVM Cross MVVM foundation Onyx MVVM Light Toolkit Cinch Jounce Core MVVM Ocean Prism Reactive UI Goldlight Catel 19.01.2014 / 12
  12. 12. MVVM Light Toolkit • • • • • • • By Laurent Bugnion Small and simple Breaking the monotony Essentials library Extras library Project templates Code snippets 19.01.2014 / 13
  13. 13. ViewModelBase • Utility class that ViewModel inherits from • Eliminates code duplication • Introduces the RaisePropertyChanged method, among others 19.01.2014 / 14
  14. 14. EventToCommand • Enables the passing of arguments to the ViewModel through the Command • Interaction triggers are used on top, for events (that fire the command) 19.01.2014 / 15
  15. 15. RelayCommand • An alternative to Command and RoutedCommand in WPF • Also implements ICommand • Relays Execute to own defined method, therefore eliminates the need to create a class for each custom Command 19.01.2014 / 16
  16. 16. Messaging • Easier communication between ViewModels • Uses Publish-Subscribe pattern • A receiver ViewModel registeres on a specific type message • A sender ViewModel creates a message of that specific type and sends it, receiver gets it 19.01.2014 / 17
  17. 17. Messaging View View Messages ViewModel ViewModel View Messages ViewModel 19.01.2014 / 18
  18. 18. Messaging • Message: • Sender: • Receiver: 19.01.2014 / 19
  19. 19. DispatcherHelper • Useful when working on multi-threaded WPF applications • Enables the calling of a method on the UI thread from a different thread • Use this or DispatcherTimer when creating a thread, never use a Timer 19.01.2014 / 20
  20. 20. Live demo 19.01.2014 / 21
  21. 21. Future of WPF • Windows RT – No support • Windows 8 Desktop – Works • XAML usage in Windows 8 Store apps 19.01.2014 / 22
  22. 22. QUESTIONS? THANK YOU 19.01.2014 / 23
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×