SlideShare ist ein Scribd-Unternehmen logo
1 von 15
Downloaden Sie, um offline zu lesen
Getting Started
with MVVM in
(WPF / Silverlight)




NISHANTH ANIL
TECHNICAL EVANGELIST
   @nishanil | nanil@infragistics.com | nnish.com
facebook.com/InfragisticsIndia
Agenda

– Patterns
– What’s MVVM?
– Foundation (WPF concepts)
– Available Frameworks
– Your First ViewModel (demo)
– Simple Dashboard (demo)




                                @nishanil
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
MVVM




       @nishanil
Foundation – WPF Concepts

•   INotifyPropertyChanged/INotifyCollectionChanged
•   DataContext
•   DataBinding
•   Commanding




                                                      @nishanil
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
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
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
Available Frameworks




Source: Wikipedia, As on 31st OCT 2012   @nishanil
Some helper files

• MVVM Foundation
  – http://mvvmfoundation.codeplex.com/
  – ObservableObject Class
  – RelayCommand




                                          @nishanil
Demo


• Writing your first ViewModel
• A simple Sales dashboard




                                 @nishanil
Silverlight: MVVM + RIA




                          @nishanil
Resources

• 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/

                                                                @nishanil
Q&A
NISHANTH ANIL
TECHNICAL EVANGELIST
   @nishanil | nanil@infragistics.com | nnish.com
facebook.com/InfragisticsIndia

Weitere ähnliche Inhalte

Ähnlich wie Infragistics: Getting Started with MVVM in WPF & Silverlight

Building databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with KnockoutjsBuilding databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with KnockoutjsNish Anil
 
Advanced MVVM in Windows 8
Advanced MVVM in Windows 8Advanced MVVM in Windows 8
Advanced MVVM in Windows 8Gill Cleeren
 
Prism library and MVVM
Prism library and MVVMPrism library and MVVM
Prism library and MVVMJiri Danihelka
 
MVVM - Model View ViewModel
MVVM - Model View ViewModelMVVM - Model View ViewModel
MVVM - Model View ViewModelDareen Alhiyari
 
Real World Windows Phone Development
Real World Windows Phone DevelopmentReal World Windows Phone Development
Real World Windows Phone DevelopmentIgor Kulman
 
Building mvvm & single pageapps in js
Building mvvm & single pageapps in jsBuilding mvvm & single pageapps in js
Building mvvm & single pageapps in jsNish Anil
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring FrameworkASG
 
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesMobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesQamar Abbas
 
E-Commerce Applications Development
E-Commerce Applications Development E-Commerce Applications Development
E-Commerce Applications Development Muhammad Sajid
 
ASP.NET MVC Best Practices malisa ncube
ASP.NET MVC Best Practices   malisa ncubeASP.NET MVC Best Practices   malisa ncube
ASP.NET MVC Best Practices malisa ncubeMalisa Ncube
 
User-tailored Inter-Widget Communication Extending the Shared Data Interface ...
User-tailored Inter-Widget Communication Extending the Shared Data Interface ...User-tailored Inter-Widget Communication Extending the Shared Data Interface ...
User-tailored Inter-Widget Communication Extending the Shared Data Interface ...Hendrik Drachsler
 
Stephen Pope - Sitecore on the bleeding edge
Stephen Pope - Sitecore on the bleeding edgeStephen Pope - Sitecore on the bleeding edge
Stephen Pope - Sitecore on the bleeding edgeNordicSitecoreConference
 
Knockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockoutKnockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockoutAndoni Arroyo
 
DDD Tactical Design with Clean Architecture - Ivan Paulovich
DDD Tactical Design with Clean Architecture - Ivan PaulovichDDD Tactical Design with Clean Architecture - Ivan Paulovich
DDD Tactical Design with Clean Architecture - Ivan PaulovichIvan Paulovich
 

Ähnlich wie Infragistics: Getting Started with MVVM in WPF & Silverlight (20)

Building databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with KnockoutjsBuilding databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with Knockoutjs
 
Advanced MVVM in Windows 8
Advanced MVVM in Windows 8Advanced MVVM in Windows 8
Advanced MVVM in Windows 8
 
Prism library and MVVM
Prism library and MVVMPrism library and MVVM
Prism library and MVVM
 
MVVM - Model View ViewModel
MVVM - Model View ViewModelMVVM - Model View ViewModel
MVVM - Model View ViewModel
 
Real World Windows Phone Development
Real World Windows Phone DevelopmentReal World Windows Phone Development
Real World Windows Phone Development
 
Building mvvm & single pageapps in js
Building mvvm & single pageapps in jsBuilding mvvm & single pageapps in js
Building mvvm & single pageapps in js
 
Adopting MVVM
Adopting MVVMAdopting MVVM
Adopting MVVM
 
Asp 1a-aspnetmvc
Asp 1a-aspnetmvcAsp 1a-aspnetmvc
Asp 1a-aspnetmvc
 
Aspnetmvc 1
Aspnetmvc 1Aspnetmvc 1
Aspnetmvc 1
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesMobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelines
 
E-Commerce Applications Development
E-Commerce Applications Development E-Commerce Applications Development
E-Commerce Applications Development
 
ASP.NET MVC Best Practices malisa ncube
ASP.NET MVC Best Practices   malisa ncubeASP.NET MVC Best Practices   malisa ncube
ASP.NET MVC Best Practices malisa ncube
 
User-tailored Inter-Widget Communication Extending the Shared Data Interface ...
User-tailored Inter-Widget Communication Extending the Shared Data Interface ...User-tailored Inter-Widget Communication Extending the Shared Data Interface ...
User-tailored Inter-Widget Communication Extending the Shared Data Interface ...
 
Stephen Pope - Sitecore on the bleeding edge
Stephen Pope - Sitecore on the bleeding edgeStephen Pope - Sitecore on the bleeding edge
Stephen Pope - Sitecore on the bleeding edge
 
Knockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockoutKnockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockout
 
Diving Into Xamarin.Forms
Diving Into Xamarin.Forms Diving Into Xamarin.Forms
Diving Into Xamarin.Forms
 
Mini-Training: NancyFX
Mini-Training: NancyFXMini-Training: NancyFX
Mini-Training: NancyFX
 
DDD Tactical Design with Clean Architecture - Ivan Paulovich
DDD Tactical Design with Clean Architecture - Ivan PaulovichDDD Tactical Design with Clean Architecture - Ivan Paulovich
DDD Tactical Design with Clean Architecture - Ivan Paulovich
 
An Introduction to IaaS Framework
An Introduction to IaaS FrameworkAn Introduction to IaaS Framework
An Introduction to IaaS Framework
 

Mehr von Nish Anil

[MobConf] Go mobile with C#, Visual Studio & Xamarin
[MobConf] Go mobile with C#, Visual Studio & Xamarin[MobConf] Go mobile with C#, Visual Studio & Xamarin
[MobConf] Go mobile with C#, Visual Studio & XamarinNish Anil
 
[MobConf] Programming wearables in c#
[MobConf] Programming wearables in c#[MobConf] Programming wearables in c#
[MobConf] Programming wearables in c#Nish Anil
 
APAC Webinar: Say Hello To Xamarin.Forms
APAC Webinar: Say Hello To Xamarin.FormsAPAC Webinar: Say Hello To Xamarin.Forms
APAC Webinar: Say Hello To Xamarin.FormsNish Anil
 
[Bdotnet] Cloud connected mobile apps
[Bdotnet] Cloud connected mobile apps[Bdotnet] Cloud connected mobile apps
[Bdotnet] Cloud connected mobile appsNish Anil
 
Evolve recap XHackers, Bangalore
Evolve recap XHackers, BangaloreEvolve recap XHackers, Bangalore
Evolve recap XHackers, BangaloreNish Anil
 
iOS & Android Dev in C# & Visual Studio using Xamarin
iOS & Android Dev in C# & Visual Studio using XamariniOS & Android Dev in C# & Visual Studio using Xamarin
iOS & Android Dev in C# & Visual Studio using XamarinNish Anil
 

Mehr von Nish Anil (6)

[MobConf] Go mobile with C#, Visual Studio & Xamarin
[MobConf] Go mobile with C#, Visual Studio & Xamarin[MobConf] Go mobile with C#, Visual Studio & Xamarin
[MobConf] Go mobile with C#, Visual Studio & Xamarin
 
[MobConf] Programming wearables in c#
[MobConf] Programming wearables in c#[MobConf] Programming wearables in c#
[MobConf] Programming wearables in c#
 
APAC Webinar: Say Hello To Xamarin.Forms
APAC Webinar: Say Hello To Xamarin.FormsAPAC Webinar: Say Hello To Xamarin.Forms
APAC Webinar: Say Hello To Xamarin.Forms
 
[Bdotnet] Cloud connected mobile apps
[Bdotnet] Cloud connected mobile apps[Bdotnet] Cloud connected mobile apps
[Bdotnet] Cloud connected mobile apps
 
Evolve recap XHackers, Bangalore
Evolve recap XHackers, BangaloreEvolve recap XHackers, Bangalore
Evolve recap XHackers, Bangalore
 
iOS & Android Dev in C# & Visual Studio using Xamarin
iOS & Android Dev in C# & Visual Studio using XamariniOS & Android Dev in C# & Visual Studio using Xamarin
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
  • 5. MVVM @nishanil
  • 6. Foundation – WPF Concepts • INotifyPropertyChanged/INotifyCollectionChanged • DataContext • DataBinding • Commanding @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
  • 10. Available Frameworks Source: Wikipedia, As on 31st OCT 2012 @nishanil
  • 11. Some helper files • MVVM Foundation – http://mvvmfoundation.codeplex.com/ – ObservableObject Class – RelayCommand @nishanil
  • 12. Demo • Writing your first ViewModel • A simple Sales dashboard @nishanil
  • 13. Silverlight: MVVM + RIA @nishanil
  • 14. Resources • 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/ @nishanil
  • 15. Q&A NISHANTH ANIL TECHNICAL EVANGELIST @nishanil | nanil@infragistics.com | nnish.com facebook.com/InfragisticsIndia