build better wpf & silverlight applications · 2018-10-13 · • prism = patterns for building...

21

Upload: others

Post on 18-Apr-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Build Better WPF & Silverlight applications · 2018-10-13 · • Prism = Patterns For Building Client Apps Client Application Challenges • Prism ... Model View Presentation. Model
Page 2: Build Better WPF & Silverlight applications · 2018-10-13 · • Prism = Patterns For Building Client Apps Client Application Challenges • Prism ... Model View Presentation. Model

Build Better WPF & Silverlight applications

using Prism v2

Page 3: Build Better WPF & Silverlight applications · 2018-10-13 · • Prism = Patterns For Building Client Apps Client Application Challenges • Prism ... Model View Presentation. Model

• The Problem:– Client Applications can be Difficult!– How Do You Make The Application

Dynamic, Customizable, Extensible, Testable?

• The Solution:– Break Application Into Modules– Manage Dependencies & Interactions– Re-assemble Application From Modules

• Prism = Patterns For Building Client Apps

Client Application Challenges

Page 4: Build Better WPF & Silverlight applications · 2018-10-13 · • Prism = Patterns For Building Client Apps Client Application Challenges • Prism ... Model View Presentation. Model

• 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 – WPF & Silverlight– Released Feb 2009

• Prism 4.0 – WPF & Silverlight 4.0– Coming Soon!

What’s In The Box?

Page 5: Build Better WPF & Silverlight applications · 2018-10-13 · • Prism = Patterns For Building Client Apps Client Application Challenges • Prism ... Model View Presentation. Model

Prism Core Concepts

Page 6: Build Better WPF & Silverlight applications · 2018-10-13 · • Prism = Patterns For Building Client Apps Client Application Challenges • Prism ... Model View Presentation. Model

Reference Implementation

Page 7: Build Better WPF & Silverlight applications · 2018-10-13 · • Prism = Patterns For Building Client Apps Client Application Challenges • Prism ... Model View Presentation. Model

Prism Quick Start Templates

Available From : http://blogs.msdn.com/dphill

Page 8: Build Better WPF & Silverlight applications · 2018-10-13 · • Prism = Patterns For Building Client Apps Client Application Challenges • Prism ... Model View Presentation. Model

• StockTrader Reference Implementation

Page 9: Build Better WPF & Silverlight applications · 2018-10-13 · • Prism = Patterns For Building Client Apps Client Application Challenges • Prism ... Model View Presentation. Model

What Are Modules?• Unit Of Application Assembly

– Collection of Related Components– Feature, Services, Views, Data Access– Slice & Dice: Mandatory, Optional, Role Specific

• Unit Of Development– Independent Development– Independent Testing

• Unit Of Deployment– Up-Front, Background or On-Demand

Page 10: Build Better WPF & Silverlight applications · 2018-10-13 · • Prism = Patterns For Building Client Apps Client Application Challenges • Prism ... Model View Presentation. Model

Finding & Loading Modules• Module Discovery

– Pluggable Module Catalogs

• Module Loading– Background or On-Demand

Module Loader

Page 11: Build Better WPF & Silverlight applications · 2018-10-13 · • Prism = Patterns For Building Client Apps Client Application Challenges • Prism ... Model View Presentation. Model

• Shell – Application Host Window• Regions – Named Areas For View Placement• Views – Module UI & Presentation Logic• Using Code to Show Views:

Building the UI

Region

Region

Region

<ContentControlRegionManager.RegionName=“BuySellRegion” />

MyView view = …;

IRegion buySellRegion =regionManager.Regions[ “BuySellRegion" ];

buySellRegion.Add( view );

<ItemsControlRegionManager.RegionName=“DataRegion">

Page 12: Build Better WPF & Silverlight applications · 2018-10-13 · • Prism = Patterns For Building Client Apps Client Application Challenges • Prism ... Model View Presentation. Model

• Automatically Showing Views:– Less Complex– Black Box ‘App Assembly’ Composition– Select Views & Pull into Region

Building the UI

Region

Region

Region

<ContentControlRegionManager.RegionName=“BuySellRegion” />

regionManager.RegisterViewType(“BuySellRegion", typeof( BuySellView ) );

Page 13: Build Better WPF & Silverlight applications · 2018-10-13 · • Prism = Patterns For Building Client Apps Client Application Challenges • Prism ... Model View Presentation. Model

• Common UI Patterns– Supervising Presenter– Presentation Model (“Model-View-ViewModel”)

• Views:– Encapsulate UI & UI Logic– Minimal Code Behind– UI Designer Friendly

• Presenters:– Presentation Logic

& State– Unit Testable– View Independent

Separated Presentation

SupervisingPresenter

Model

View

PresentationModel ModelView

Page 14: Build Better WPF & Silverlight applications · 2018-10-13 · • Prism = Patterns For Building Client Apps Client Application Challenges • Prism ... Model View Presentation. Model

Commands and Events• Delegate Commands

– Delegate Based Commanding Pattern

• Composite Commands– Multiple Handler Command Routing

• Event Aggregator– Loosely Coupled Pub/Sub Events

Module BCustomerPresenter

Module AOrder

Presenter

EventAggregator

SubscribePublishEvent

Page 15: Build Better WPF & Silverlight applications · 2018-10-13 · • Prism = Patterns For Building Client Apps Client Application Challenges • Prism ... Model View Presentation. Model

• Separated Presentation

Page 16: Build Better WPF & Silverlight applications · 2018-10-13 · • Prism = Patterns For Building Client Apps Client Application Challenges • Prism ... Model View Presentation. Model

WPF

SILV

ERLI

GH

T

CLR - Silverlight CLR Desktop

BCL BCL

BROWSER DESKTOP

Multi-Targeting• Desktop vs RIA Applications

– Desktop: In the Office, Full FunctionalityOffline Capable

– RIA: Out of the Office, Functional Subset, Online Only

Controllers

Models

Presenters

Views

Models

Controllers

Presenters

Views

Page 17: Build Better WPF & Silverlight applications · 2018-10-13 · • Prism = Patterns For Building Client Apps Client Application Challenges • Prism ... Model View Presentation. Model

• Multi-Targeting

Page 18: Build Better WPF & Silverlight applications · 2018-10-13 · • Prism = Patterns For Building Client Apps Client Application Challenges • Prism ... Model View Presentation. Model

• Library of Patterns for Client & RIA Applications– Modularity, Composition, Separated Presentation…

• Solid but Flexible Architectural Foundation– Promotes Re-use, Unit Testing, Independent Development– Supports Design-Time & Run-Time Extensibility

• Multi-Targeting– Promotes Re-use across WPF & Silverlight– Support Multi User Experience or Migration

• Code, Reference Implementation, Documentation & Quick-Starts Available on MSDN & CodePlex

• What’s Next?– Next Release for WPF & Silverlight 4.0 Spring 2010– Send us feedback & ideas for Prism 4.0!

Summary

Page 19: Build Better WPF & Silverlight applications · 2018-10-13 · • Prism = Patterns For Building Client Apps Client Application Challenges • Prism ... Model View Presentation. Model

Prism Roadmap

• What’s Coming in Prism 4.0?– Silverlight 4.0 and WPF 4.0 Support– More ViewModel Pattern Guidance– Managed Extensibility Framework (MEF) Support– Guidance For Out of Browser Applications– ???

2009 2010

3.0 4.0

Prism 2.0 Prism 2.1 Prism 4.0

Page 20: Build Better WPF & Silverlight applications · 2018-10-13 · • Prism = Patterns For Building Client Apps Client Application Challenges • Prism ... Model View Presentation. Model

Where Can You Find It?• www.microsoft.com/prism• www.codeplex.com/prism

Page 21: Build Better WPF & Silverlight applications · 2018-10-13 · • Prism = Patterns For Building Client Apps Client Application Challenges • Prism ... Model View Presentation. Model

© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market

conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.