infragistics: getting started with mvvm in wpf & silverlight
DESCRIPTION
OCT 31 Webinar SlidesTRANSCRIPT
NISHANTH ANIL
TECHNICAL EVANGELIST
| [email protected] | nnish.com
facebook.com/InfragisticsIndia
Getting Started with MVVM in (WPF / Silverlight)
@nishanil
– Patterns
– What’s MVVM?
– Foundation (WPF concepts)
– Available Frameworks
– Your First ViewModel (demo)
– Simple Dashboard (demo)
Agenda
@nishanil
• UI patterns – Model – View – Controller
– Model – View – Presenter
– Presentation Model
– Model – View – ViewModel
• Why do they exist? – Separation of concerns
– Testability
– Maintainability
Patterns – are guidelines not rules!
@nishanil
MVVM
@nishanil
• INotifyPropertyChanged/INotifyCollectionChanged
• DataContext
• DataBinding
• Commanding
Foundation – WPF Concepts
@nishanil
• INotifyPropertyChanged – Not a WPF only concept (part of an implementation of GOF Observer pattern)
• Observer Pattern in brief: When one object changes state, all its dependents are notified and updated automatically.
– Implement INotifyPropertyChanged in your ViewModels
– And Notify when property changes
• INotifyCollectionChanged – Similar to INotifyProperyChanged, but it applies to collections of objects
– Use ObservableCollection<T> instead of manually implementing
Foundation – WPF Concepts
@nishanil
• DataBinding – A View binds to properties on a ViewModel
• DataContext – Set ViewModel to the DataContext of the View
– This property is meant to be set to the data object it visualizes.
Foundation – WPF Concepts
@nishanil
• Commanding – Is an input mechanism
– Without command MVVM will be less powerful
– Commands in WPF are implemented using ICommand interface
Binding the command in the View
Foundation – WPF Concepts
@nishanil
ViewModel
ICommand Implementation
Available Frameworks
@nishanil Source: Wikipedia, As on 31st OCT 2012
• MVVM Foundation
– http://mvvmfoundation.codeplex.com/
– ObservableObject Class
– RelayCommand
Some helper files
@nishanil
• Writing your first ViewModel
• A simple Sales dashboard
Demo
@nishanil
Silverlight: MVVM + RIA
@nishanil
• Introduction to Model/View/ViewModel pattern for building WPF apps (John Gossman) – http://blogs.msdn.com/b/johngossman/archive/2005/10/08/478683.a
spx
• WPF Apps With The Model-View-ViewModel Design Pattern (Josh Smith) – http://msdn.microsoft.com/en-us/magazine/dd419663.aspx
• Infragistics Community – http://www.infragistics.com/community/blogs/
• Infragistics WPF Products - http://www.infragistics.com/products/wpf/
• Infragistics Silverlight Products - http://www.infragistics.com/products/silverlight/
Resources
@nishanil
Q&A
NISHANTH ANIL
TECHNICAL EVANGELIST
| [email protected] | nnish.com
facebook.com/InfragisticsIndia
@nishanil