Behaviors In WPF & Silverlight Silicon Valley Code Camp 2009
Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)
-
Upload
dave-bost -
Category
Technology
-
view
2.026 -
download
0
description
Transcript of Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)
![Page 1: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/1.jpg)
Shine a Light withShine a Light with“Prism”“Prism”Dave BostDave BostDeveloper Evangelisthttp://davebost.com/blog
Pre-requisites for this presentation:
1) IoC, DI 2) Presentation patterns
Level: Intermediate
![Page 2: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/2.jpg)
http://thirstydeveloper.comhttp://thirstydeveloper.com
“Looking at someone’s code, but with audio”
![Page 3: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/3.jpg)
Session Objectives And Session Objectives And TakeawaysTakeaways Session Objective(s):
– Able to determine RIA composite application scenarios and recommend solutions for the scenarios using Prism for Silverlight and WPF.
Prism – V2 in Feb shipped Feb. ‘09 (Silverlight) Provides written and code-example guidance
for composite solution space Supports targeting both Silverlight & WPF
composite applications
![Page 4: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/4.jpg)
Are you building this?Are you building this?
![Page 5: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/5.jpg)
Or something like this?Or something like this?
![Page 6: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/6.jpg)
The ChallengeThe Challenge
![Page 7: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/7.jpg)
The SolutionThe Solution
![Page 8: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/8.jpg)
Consider PrismConsider Prism
Provides Tools to help with separating your app and composing at run-time:
• Tools to help you discover the pieces• Strategies and guidance for recomposition• Approaches for communication between these separate components• Event help with targeting both Silverlight and WPF
Provides Tools to help with separating your app and composing at run-time:
• Tools to help you discover the pieces• Strategies and guidance for recomposition• Approaches for communication between these separate components• Event help with targeting both Silverlight and WPF
![Page 9: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/9.jpg)
Prism-What’s in the boxPrism-What’s in the box
Prism – Composite Client Application Guidance for WPF and Silverlight– Library– Reference Implementation– Documentation– Quick-Starts & How-To’s– Community – CodePlex
Prism 1.0 – WPF– Released July 2008
Prism 2.0 – Silverlight– Released February 2009
![Page 10: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/10.jpg)
Reference ImplementationReference Implementation
![Page 11: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/11.jpg)
Prism Core ConceptsPrism Core Concepts
![Page 12: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/12.jpg)
ModulesModules
Unit Of Application Assembly– Collection of Related Components
– Feature, Services, Views, Data Access
– Mandatory or Optional or Role Specific
– Example: Banking app: Checking Module, Credit Card Module, Trading Module, News Module
Unit Of Development– Independent Development
– Independent Testing
Unit Of Deployment– Up-Front, Background or On-Demand
![Page 13: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/13.jpg)
ModulesModules Module Discovery
– Pluggable Catalogs
Module Loading– Background or On-Demand
Module Module LoaderLoaderModule Module LoaderLoader
Extended InExtended InPrism 2.0!Prism 2.0!
![Page 14: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/14.jpg)
DemoDemo
Modules & Catalogs
![Page 15: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/15.jpg)
UI CompositionUI Composition Shell – Application Host Window Regions – Named Areas For View Placement Views – Encapsulate UI & Presentation Logic
RegionRegion
RegionRegion
RegionRegion
// View InjectionIPositionPresentationModel presentationModel = …;
IRegion mainRegion = regionManager.Regions[ "MainRegion" ];
mainRegion.Add( presentationModel.View );
<TabControl RegionManager.RegionName= "MainRegion">
<ItemsControl RegionManager.RegionName= “ResearchRegion” />
<ContentControlRegionManager.RegionName= “ActionRegion” />
![Page 16: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/16.jpg)
UI CompositionUI Composition View Discovery Composition:
– Less Complex– Black Box ‘App Assembly’ Composition– Select Views & Pull into Region
New InNew InPrism 2.0!
Prism 2.0!
RegionRegion
RegionRegion
RegionRegion
<TabControl RegionManager.RegionName= "MainRegion">
regionManager. RegisterViewWithRegion( "MainRegion", typeof( MainView ) );
![Page 17: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/17.jpg)
DemoDemo
UI Composition
![Page 18: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/18.jpg)
Commands and EventsCommands and Events
Delegate & Composite Commands– Simplified Command Handling
Event Aggregator– Loosely Coupled Pub/Sub Events
Module BModule B
CustomerPresenterCustomerPresenter
Module AModule A
OrderPresenter
OrderPresenter
EventAggregator
EventAggregator
Subscribe
Publish
Event
![Page 19: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/19.jpg)
Prism Silverlight Logical Prism Silverlight Logical ArchitectureArchitecture
HOST APPLICATIONHOST APPLICATION LOADING SERVICESLOADING SERVICES
CORE SERVICESCORE SERVICES
MODULE PROFFERED SERVICES
MODULE PROFFERED SERVICES
ModulesModulesMODULESMODULES
PresenterPresenter
ModelModel
ViewView
ModelModel
ModuleCatalog
Module Loader
EventAggregator
Logging
RegionManager
Un
ity
Module Initializer
![Page 20: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/20.jpg)
Multi-TargetingMulti-Targeting User Experiences
– Desktop – In the Office, Full Functionality, Offline – RIA – Out of the Office, Functional Subset, Online
WPFApplication
WPFApplication
Silverlight (RIA)Application
Silverlight (RIA)Application
CLR - SilverlightCLR - SilverlightCLR - SilverlightCLR - Silverlight CLR DesktopCLR DesktopCLR DesktopCLR Desktop
BCLBCLBCLBCL BCLBCLBCLBCL
BROWSER DESKTOP
![Page 21: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/21.jpg)
Multi-Targeting: StrategiesMulti-Targeting: Strategies
Start with LCD Use Links and Parallel Project Structures Separated Presentation Strategies Keep single source If not, apply the sieve
#IF SILVERLIGHT#IF SILVERLIGHT
Partial ClassesPartial Classes
Partial MethodsPartial Methods
Separate ClassesSeparate Classes
Rewrite the CodeRewrite the Code
![Page 22: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/22.jpg)
WP
FW
PF
CLR - SilverlightCLR - SilverlightCLR - SilverlightCLR - Silverlight CLR DesktopCLR DesktopCLR DesktopCLR Desktop
BCLBCLBCLBCL BCLBCLBCLBCL
BROWSER DESKTOP
Multi-TargetingMulti-Targeting
ControllersControllers
ModelsModels
PresentersPresenters
ViewsViews
ModelsModels
ControllersControllers
PresentersPresenters
ViewsViews
![Page 23: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/23.jpg)
DemoDemo
Multi-Targeting
![Page 24: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/24.jpg)
Where Can You Find It?Where Can You Find It?
www.microsoft.com/compositewpf www.codeplex.com/compositewpf http://msdn.microsoft.com/practices http://blogs.msdn.com/bobbrum http://blogs.msdn.com/blaine
![Page 25: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/25.jpg)
SummarySummary
Prism– Library of Patterns for Composite Client Applications– Targets WPF Desktop and Silverlight RIA Applications– View Disovery Composition, Separated Presentation
Patterns, Module Catalog– Multi-Targeting to reuse code between Silverlight and
WPF
Download from CodePlex and send us feedback
![Page 26: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/26.jpg)
Dave Bost
thank you!
http://davebost.comhttp://twitter.com/davebost
Q&A
![Page 27: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/27.jpg)
![Page 28: Shine a Light with Prism (the Composite Application Guidance for WPF and Silverlight)](https://reader035.fdocuments.us/reader035/viewer/2022070302/548c9e7db47959e7368b46e6/html5/thumbnails/28.jpg)