SlideShare une entreprise Scribd logo
1  sur  31
MVVM + MEF in Silverlight Ricardo Fiel
Who’s that guy? xamlpt.com/blogs/rfiel/ pontonetpt.com/blogs/rfiel/ blogs.fullsix.pt labs.fullsix.pt Ricardo Fiel Senior Engineer Fullsix Portugal ricardo.fiel@fullsix.com @theplastictoy
Agenda The “easy” way MVVM – Model View ViewModel MEF – Managed Extensibility Framework Scenarios for MVVM + MEF together Q&A
The “easy” way
Question 	What are some of the biggest costs in Software Development? ,[object Object]
Bug fixing
?,[object Object]
That was the DANGEROUS way! Too much coupling Very hard to test Developer-Designer workflow issues Maintenance will be a pain Looks faster, but will become expensive It’s not always the wrong way, but USE IT WITH CAUTION!
MV* patterns Different people reading about MVC in different places take different ideas from it and describe these as “MVC”. Presentation Model is of a fully self-contained class that represents all the data and behavior of the UI, but without any of the controls used to render that UI on the screen. A view then simply projects the state of the presentation model onto the glass. The most annoying part of Presentation Model is the synchronization between Presentation Model and view… Ideally some kind of framework could handle this, which I'm hoping will happen some day with technologies like .NET's data binding. Martin Fowler, 2004
MVVMModel-View-ViewModel Ladies and gentleman, may I introduce you to:
The MVVM triad View Display data in Controls UI Friendly Entities, UI State, Actions Entities representing data ViewModel Model
Model Represents the data The entity Not required to know where it gets its data from From a WCF service. WCF RIA Services, etc May contain validation
View The screen, the UI, the UserControl in Silverlight Handles UI look and feel Presentation of information Communicates with ViewModel through bindings
ViewModel Main source of logic for the MVVM triad Connects the Model to the View Abstracts the View Public properties that are bound to a View INotifyPropertyChangedand INotifyCollectionChangedtalk to the View through bindings Listens for changes from the View through bindings May invoke services to communicate outside the MVVM triad
MVVM Variations - 1 View First ViewModel is created as a StaticResource in the View’s XAML or in the View’s code-behind Excellent for Blend (“Blendability”) <UserControl.Resources> <data:GamesViewModel x:Key="TheViewModel" />   </UserControl.Resources>   <Grid DataContext="{Binding Path=Games,                        Source={StaticResourceTheViewModel}}">   ...   </Grid>
MVVM Variations - 2 ViewModel first View is injected into the ViewModel’sconstructor Example: ViewModel is created then the View is created using Dependency Injection public MyViewModel {   public MyViewModel(IMyView view)   {   } }
MVVM Variations - 3 ViewModel and View are created through an intermediary, then paired together vm = new MyVM(); view = new MyView(); view.DataContext = vm; // With Unity vm = container.Resolve<IMyVM>(); view = container.Resolve<MyView>(); view.DataContext = vm;
From Now On We’re Using ViewFirst <3
Don’t look up! View only knows ViewModel ViewModel only knows Model The Model stands alone
ICommand interface Available in Silverlight 4 ButtonBase and Hyperlink now have Command and CommandParameter properties <Button Content="Load Products" Width="120"   Command="{Binding FindMatchingProducts}"   CommandParameter="{Binding Path=Text, ElementName=CostThresholdFilter}"/> public interface ICommand { boolCanExecute(Object parameter); 	void Execute(Object parameter); 	event EventHandlerCanExecuteChanged; )
Tools to make it simple There are several tools available: Prism www.codeplex.com/CompositeWPF Caliburn www.codeplex.com/caliburn Silverlight.FX projects.nikhilk.net/SilverlightFX MVVM Light Toolkit www.codeplex.com/mvvmlight You can build your own MVVM framework Comparison list at http://www.japf.fr/silverlight/mvvm/index.html
demo ViewFirst MVVM
MEFManaged Extensibility Framework
MEF Intro Library for building extensible applications Part of Silverlight 4 Silverlight 3 support 	mef.codeplex.com Prism support mefcontrib.codeplex.com Open source
MEF Basics An application is built of Parts
The MEF “Motto” Exportit. Import it. Composeit.
Export it [Export(typeof(UserControl))] public class Widget1 : UserControl { 	public string Message { 	     get{return(string) Button.Content;}                     set{Button.Content=value;}                } } Widget1 UserControl Export
Import it [Export(typeof(UserControl))] public class MainPage: UserControl { 	[ImportMany(typeof(UserControl))] 	public IEnumerable<UserControl> { get;set; 	} } Main Page UserControl ImportMany
Compose it PartIntializer: “Compose yourself”  public MainPage()  { InitializeComponent(); PartInitializer.SatisfyImports(this);  } MainPage Compose
demo Adding social widgets
Scenarios MVVM + MEF together? I, MVVM, take you MEF, to be my wife, to have and to hold from this day forward, for better or for worse, for richer, for poorer, in sickness and in health, to love and to cherish; from this day forward until death do us part.

Contenu connexe

Tendances

ASP .NET MVC Introduction & Guidelines
ASP .NET MVC Introduction & Guidelines  ASP .NET MVC Introduction & Guidelines
ASP .NET MVC Introduction & Guidelines Dev Raj Gautam
 
MVC Seminar Presantation
MVC Seminar PresantationMVC Seminar Presantation
MVC Seminar PresantationAbhishek Yadav
 
MVVM - Model View ViewModel
MVVM - Model View ViewModelMVVM - Model View ViewModel
MVVM - Model View ViewModelDareen Alhiyari
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )Ahmed Emad
 
MVC for Desktop Application - Part 2
MVC for Desktop Application - Part  2MVC for Desktop Application - Part  2
MVC for Desktop Application - Part 2晟 沈
 
What's new in asp.net mvc 4
What's new in asp.net mvc 4What's new in asp.net mvc 4
What's new in asp.net mvc 4Simone Chiaretta
 
MVC for Desktop Application - Part 3
MVC for Desktop Application - Part 3MVC for Desktop Application - Part 3
MVC for Desktop Application - Part 3晟 沈
 
MVC for Desktop Application - Part 1
MVC for Desktop Application - Part 1MVC for Desktop Application - Part 1
MVC for Desktop Application - Part 1晟 沈
 
Model View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In AspnetModel View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In Aspnetrainynovember12
 
Principles of MVC for PHP Developers
Principles of MVC for PHP DevelopersPrinciples of MVC for PHP Developers
Principles of MVC for PHP DevelopersEdureka!
 
Introduction To Model View Presenter
Introduction To Model View PresenterIntroduction To Model View Presenter
Introduction To Model View Presentersaeed shargi ghazani
 
MVC for Desktop Application - Part 4
MVC for Desktop Application - Part 4MVC for Desktop Application - Part 4
MVC for Desktop Application - Part 4晟 沈
 
Design Pattern - MVC, MVP and MVVM
Design Pattern - MVC, MVP and MVVMDesign Pattern - MVC, MVP and MVVM
Design Pattern - MVC, MVP and MVVMMudasir Qazi
 
3-TIER ARCHITECTURE IN ASP.NET MVC
3-TIER ARCHITECTURE IN ASP.NET MVC3-TIER ARCHITECTURE IN ASP.NET MVC
3-TIER ARCHITECTURE IN ASP.NET MVCMohd Manzoor Ahmed
 
Introduction to angular js for .net developers
Introduction to angular js  for .net developersIntroduction to angular js  for .net developers
Introduction to angular js for .net developersMohd Manzoor Ahmed
 
A report on mvc using the information
A report on mvc using the informationA report on mvc using the information
A report on mvc using the informationToushik Paul
 

Tendances (20)

ASP .NET MVC Introduction & Guidelines
ASP .NET MVC Introduction & Guidelines  ASP .NET MVC Introduction & Guidelines
ASP .NET MVC Introduction & Guidelines
 
MVC Seminar Presantation
MVC Seminar PresantationMVC Seminar Presantation
MVC Seminar Presantation
 
MVVM - Model View ViewModel
MVVM - Model View ViewModelMVVM - Model View ViewModel
MVVM - Model View ViewModel
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )
 
MVC for Desktop Application - Part 2
MVC for Desktop Application - Part  2MVC for Desktop Application - Part  2
MVC for Desktop Application - Part 2
 
What's new in asp.net mvc 4
What's new in asp.net mvc 4What's new in asp.net mvc 4
What's new in asp.net mvc 4
 
MVC for Desktop Application - Part 3
MVC for Desktop Application - Part 3MVC for Desktop Application - Part 3
MVC for Desktop Application - Part 3
 
MVC for Desktop Application - Part 1
MVC for Desktop Application - Part 1MVC for Desktop Application - Part 1
MVC for Desktop Application - Part 1
 
No brainer
No brainerNo brainer
No brainer
 
MVVM In Use
MVVM In UseMVVM In Use
MVVM In Use
 
ASP.NET MVC 3
ASP.NET MVC 3ASP.NET MVC 3
ASP.NET MVC 3
 
Introduction to Angular Js
Introduction to Angular JsIntroduction to Angular Js
Introduction to Angular Js
 
Model View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In AspnetModel View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In Aspnet
 
Principles of MVC for PHP Developers
Principles of MVC for PHP DevelopersPrinciples of MVC for PHP Developers
Principles of MVC for PHP Developers
 
Introduction To Model View Presenter
Introduction To Model View PresenterIntroduction To Model View Presenter
Introduction To Model View Presenter
 
MVC for Desktop Application - Part 4
MVC for Desktop Application - Part 4MVC for Desktop Application - Part 4
MVC for Desktop Application - Part 4
 
Design Pattern - MVC, MVP and MVVM
Design Pattern - MVC, MVP and MVVMDesign Pattern - MVC, MVP and MVVM
Design Pattern - MVC, MVP and MVVM
 
3-TIER ARCHITECTURE IN ASP.NET MVC
3-TIER ARCHITECTURE IN ASP.NET MVC3-TIER ARCHITECTURE IN ASP.NET MVC
3-TIER ARCHITECTURE IN ASP.NET MVC
 
Introduction to angular js for .net developers
Introduction to angular js  for .net developersIntroduction to angular js  for .net developers
Introduction to angular js for .net developers
 
A report on mvc using the information
A report on mvc using the informationA report on mvc using the information
A report on mvc using the information
 

En vedette

Unit Testing MVVM in Silverlight
Unit Testing MVVM in SilverlightUnit Testing MVVM in Silverlight
Unit Testing MVVM in SilverlightTimmy Kokke
 
Real-world Model-View-ViewModel for WPF
Real-world Model-View-ViewModel for WPFReal-world Model-View-ViewModel for WPF
Real-world Model-View-ViewModel for WPFPaul Stovell
 
Building an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernateBuilding an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernatebwullems
 
Silverlight in Internet Scenarios
Silverlight in Internet ScenariosSilverlight in Internet Scenarios
Silverlight in Internet ScenariosRicardo Fiel
 
Agile pt 2015 dont blindly follow
Agile pt 2015 dont blindly followAgile pt 2015 dont blindly follow
Agile pt 2015 dont blindly followRicardo Fiel
 
Lessons Learned The Hard Way - Scrum Gathering 2016
Lessons Learned The Hard Way - Scrum Gathering 2016Lessons Learned The Hard Way - Scrum Gathering 2016
Lessons Learned The Hard Way - Scrum Gathering 2016Ricardo Fiel
 
What they dont teach you at school
What they dont teach you at schoolWhat they dont teach you at school
What they dont teach you at schoolRicardo Fiel
 

En vedette (8)

Unit Testing MVVM in Silverlight
Unit Testing MVVM in SilverlightUnit Testing MVVM in Silverlight
Unit Testing MVVM in Silverlight
 
Real-world Model-View-ViewModel for WPF
Real-world Model-View-ViewModel for WPFReal-world Model-View-ViewModel for WPF
Real-world Model-View-ViewModel for WPF
 
Building an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernateBuilding an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernate
 
Adopting MVVM
Adopting MVVMAdopting MVVM
Adopting MVVM
 
Silverlight in Internet Scenarios
Silverlight in Internet ScenariosSilverlight in Internet Scenarios
Silverlight in Internet Scenarios
 
Agile pt 2015 dont blindly follow
Agile pt 2015 dont blindly followAgile pt 2015 dont blindly follow
Agile pt 2015 dont blindly follow
 
Lessons Learned The Hard Way - Scrum Gathering 2016
Lessons Learned The Hard Way - Scrum Gathering 2016Lessons Learned The Hard Way - Scrum Gathering 2016
Lessons Learned The Hard Way - Scrum Gathering 2016
 
What they dont teach you at school
What they dont teach you at schoolWhat they dont teach you at school
What they dont teach you at school
 

Similaire à MVVM+MEF in Silvelight - W 2010ebday

Modern ASP.NET Webskills
Modern ASP.NET WebskillsModern ASP.NET Webskills
Modern ASP.NET WebskillsCaleb Jenkins
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Jonas Follesø
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC StructureDipika Wadhvani
 
MVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,MobileMVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,Mobilenaral
 
Creating UX Applications that Target both Silverlight and WPF
Creating UX Applications that Target both Silverlight and WPFCreating UX Applications that Target both Silverlight and WPF
Creating UX Applications that Target both Silverlight and WPFChristian Thilmany
 
Building Composite Applications with Silverlight - Prism 2.0
Building Composite Applications with Silverlight - Prism 2.0Building Composite Applications with Silverlight - Prism 2.0
Building Composite Applications with Silverlight - Prism 2.0Christian Thilmany
 
Caliburn.micro
Caliburn.microCaliburn.micro
Caliburn.microbwullems
 
Mike Taulty MIX10 Silverlight Frameworks and Patterns
Mike Taulty MIX10 Silverlight Frameworks and PatternsMike Taulty MIX10 Silverlight Frameworks and Patterns
Mike Taulty MIX10 Silverlight Frameworks and Patternsukdpe
 
Architectural Design Pattern: Android
Architectural Design Pattern: AndroidArchitectural Design Pattern: Android
Architectural Design Pattern: AndroidJitendra Kumar
 
MVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCMVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCAnton Krasnoshchok
 
Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...
Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...
Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...Dave Bost
 
Code Camp 06 Model View Presenter Architecture
Code Camp 06   Model View Presenter ArchitectureCode Camp 06   Model View Presenter Architecture
Code Camp 06 Model View Presenter Architecturebitburner93
 
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...RapidValue
 
Building Web Application Using Spring Framework
Building Web Application Using Spring FrameworkBuilding Web Application Using Spring Framework
Building Web Application Using Spring FrameworkEdureka!
 

Similaire à MVVM+MEF in Silvelight - W 2010ebday (20)

Modern ASP.NET Webskills
Modern ASP.NET WebskillsModern ASP.NET Webskills
Modern ASP.NET Webskills
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008
 
Training: MVVM Pattern
Training: MVVM PatternTraining: MVVM Pattern
Training: MVVM Pattern
 
Fundaments of Knockout js
Fundaments of Knockout jsFundaments of Knockout js
Fundaments of Knockout js
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC Structure
 
MVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,MobileMVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,Mobile
 
Creating UX Applications that Target both Silverlight and WPF
Creating UX Applications that Target both Silverlight and WPFCreating UX Applications that Target both Silverlight and WPF
Creating UX Applications that Target both Silverlight and WPF
 
Building Composite Applications with Silverlight - Prism 2.0
Building Composite Applications with Silverlight - Prism 2.0Building Composite Applications with Silverlight - Prism 2.0
Building Composite Applications with Silverlight - Prism 2.0
 
Caliburn.micro
Caliburn.microCaliburn.micro
Caliburn.micro
 
Mike Taulty MIX10 Silverlight Frameworks and Patterns
Mike Taulty MIX10 Silverlight Frameworks and PatternsMike Taulty MIX10 Silverlight Frameworks and Patterns
Mike Taulty MIX10 Silverlight Frameworks and Patterns
 
Architectural Design Pattern: Android
Architectural Design Pattern: AndroidArchitectural Design Pattern: Android
Architectural Design Pattern: Android
 
MVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCMVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVC
 
Spring Framework-II
Spring Framework-IISpring Framework-II
Spring Framework-II
 
MSDN - ASP.NET MVC
MSDN - ASP.NET MVCMSDN - ASP.NET MVC
MSDN - ASP.NET MVC
 
Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...
Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...
Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...
 
MVVM_Ashraf
MVVM_AshrafMVVM_Ashraf
MVVM_Ashraf
 
Code Camp 06 Model View Presenter Architecture
Code Camp 06   Model View Presenter ArchitectureCode Camp 06   Model View Presenter Architecture
Code Camp 06 Model View Presenter Architecture
 
Asp.Net MVC Intro
Asp.Net MVC IntroAsp.Net MVC Intro
Asp.Net MVC Intro
 
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
 
Building Web Application Using Spring Framework
Building Web Application Using Spring FrameworkBuilding Web Application Using Spring Framework
Building Web Application Using Spring Framework
 

Dernier

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 

Dernier (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

MVVM+MEF in Silvelight - W 2010ebday

  • 1. MVVM + MEF in Silverlight Ricardo Fiel
  • 2. Who’s that guy? xamlpt.com/blogs/rfiel/ pontonetpt.com/blogs/rfiel/ blogs.fullsix.pt labs.fullsix.pt Ricardo Fiel Senior Engineer Fullsix Portugal ricardo.fiel@fullsix.com @theplastictoy
  • 3. Agenda The “easy” way MVVM – Model View ViewModel MEF – Managed Extensibility Framework Scenarios for MVVM + MEF together Q&A
  • 5.
  • 7.
  • 8. That was the DANGEROUS way! Too much coupling Very hard to test Developer-Designer workflow issues Maintenance will be a pain Looks faster, but will become expensive It’s not always the wrong way, but USE IT WITH CAUTION!
  • 9. MV* patterns Different people reading about MVC in different places take different ideas from it and describe these as “MVC”. Presentation Model is of a fully self-contained class that represents all the data and behavior of the UI, but without any of the controls used to render that UI on the screen. A view then simply projects the state of the presentation model onto the glass. The most annoying part of Presentation Model is the synchronization between Presentation Model and view… Ideally some kind of framework could handle this, which I'm hoping will happen some day with technologies like .NET's data binding. Martin Fowler, 2004
  • 10. MVVMModel-View-ViewModel Ladies and gentleman, may I introduce you to:
  • 11. The MVVM triad View Display data in Controls UI Friendly Entities, UI State, Actions Entities representing data ViewModel Model
  • 12. Model Represents the data The entity Not required to know where it gets its data from From a WCF service. WCF RIA Services, etc May contain validation
  • 13. View The screen, the UI, the UserControl in Silverlight Handles UI look and feel Presentation of information Communicates with ViewModel through bindings
  • 14. ViewModel Main source of logic for the MVVM triad Connects the Model to the View Abstracts the View Public properties that are bound to a View INotifyPropertyChangedand INotifyCollectionChangedtalk to the View through bindings Listens for changes from the View through bindings May invoke services to communicate outside the MVVM triad
  • 15. MVVM Variations - 1 View First ViewModel is created as a StaticResource in the View’s XAML or in the View’s code-behind Excellent for Blend (“Blendability”) <UserControl.Resources> <data:GamesViewModel x:Key="TheViewModel" /> </UserControl.Resources> <Grid DataContext="{Binding Path=Games, Source={StaticResourceTheViewModel}}"> ... </Grid>
  • 16. MVVM Variations - 2 ViewModel first View is injected into the ViewModel’sconstructor Example: ViewModel is created then the View is created using Dependency Injection public MyViewModel { public MyViewModel(IMyView view) { } }
  • 17. MVVM Variations - 3 ViewModel and View are created through an intermediary, then paired together vm = new MyVM(); view = new MyView(); view.DataContext = vm; // With Unity vm = container.Resolve<IMyVM>(); view = container.Resolve<MyView>(); view.DataContext = vm;
  • 18. From Now On We’re Using ViewFirst <3
  • 19. Don’t look up! View only knows ViewModel ViewModel only knows Model The Model stands alone
  • 20. ICommand interface Available in Silverlight 4 ButtonBase and Hyperlink now have Command and CommandParameter properties <Button Content="Load Products" Width="120" Command="{Binding FindMatchingProducts}" CommandParameter="{Binding Path=Text, ElementName=CostThresholdFilter}"/> public interface ICommand { boolCanExecute(Object parameter); void Execute(Object parameter); event EventHandlerCanExecuteChanged; )
  • 21. Tools to make it simple There are several tools available: Prism www.codeplex.com/CompositeWPF Caliburn www.codeplex.com/caliburn Silverlight.FX projects.nikhilk.net/SilverlightFX MVVM Light Toolkit www.codeplex.com/mvvmlight You can build your own MVVM framework Comparison list at http://www.japf.fr/silverlight/mvvm/index.html
  • 24. MEF Intro Library for building extensible applications Part of Silverlight 4 Silverlight 3 support mef.codeplex.com Prism support mefcontrib.codeplex.com Open source
  • 25. MEF Basics An application is built of Parts
  • 26. The MEF “Motto” Exportit. Import it. Composeit.
  • 27. Export it [Export(typeof(UserControl))] public class Widget1 : UserControl { public string Message { get{return(string) Button.Content;} set{Button.Content=value;} } } Widget1 UserControl Export
  • 28. Import it [Export(typeof(UserControl))] public class MainPage: UserControl { [ImportMany(typeof(UserControl))] public IEnumerable<UserControl> { get;set; } } Main Page UserControl ImportMany
  • 29. Compose it PartIntializer: “Compose yourself” public MainPage() { InitializeComponent(); PartInitializer.SatisfyImports(this); } MainPage Compose
  • 31. Scenarios MVVM + MEF together? I, MVVM, take you MEF, to be my wife, to have and to hold from this day forward, for better or for worse, for richer, for poorer, in sickness and in health, to love and to cherish; from this day forward until death do us part.
  • 32. Thanks! xamlpt.com/blogs/rfiel/ pontonetpt.com/blogs/rfiel/ blogs.fullsix.pt labs.fullsix.pt Ricardo Fiel Senior Engineer Fullsix Portugal ricardo.fiel@fullsix.com @theplastictoy Please keep in touch!