iOS & Android Dev in C# & Visual Studio using Xamarin
Infragistics: Getting Started with MVVM in WPF & Silverlight
1.
2. Getting Started
with MVVM in
(WPF / Silverlight)
NISHANTH ANIL
TECHNICAL EVANGELIST
@nishanil | nanil@infragistics.com | nnish.com
facebook.com/InfragisticsIndia
3. Agenda
– Patterns
– What’s MVVM?
– Foundation (WPF concepts)
– Available Frameworks
– Your First ViewModel (demo)
– Simple Dashboard (demo)
@nishanil
4. Patterns – are guidelines not rules!
• UI patterns
– Model – View – Controller
– Model – View – Presenter
– Presentation Model
– Model – View – ViewModel
• Why do they exist?
– Separation of concerns
– Testability
– Maintainability
@nishanil
7. Foundation – WPF Concepts
• 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
@nishanil
8. Foundation – WPF Concepts
• 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.
@nishanil
9. Foundation – WPF Concepts
• Commanding
– Is an input mechanism
– Without command MVVM will be less powerful
– Commands in WPF are implemented using ICommand interface
ICommand Implementation
ViewModel
Binding the command in the View
@nishanil