developers guide to microsoft prism 4

280 2.9K 0
developers guide to microsoft prism 4

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

• • • • • • • • • • • • • • • • • • • • • • • • • • SPINE= .4” DEVELOPER’S GUIDE TO MICROSOFT ® PRISM 4 DEVELOPER’S GUIDE TO MICROSOFT ® PRISM 4 For more information explore: msdn.microsoft.com/practices Software Architecture and Software Development U.S.A. $29.99 [Recommended] patterns & practices Proven practices for predictable results Save time and reduce risk on your software development projects by incorporating patterns & practices, Microsoft’s applied engineering guidance that includes both production quality source code and documentation. The guidance is designed to help software development teams: Make critical design and technology selection decisions by highlighting the appropriate solution architectures, technologies, and Microsoft products for common scenarios Understand the most important concepts needed for success by explaining the relevant patterns and prescribing the important practices Get started with a proven code base by providing thoroughly tested software and source that embodies Microsoft’s recommendations The patterns & practices team consists of experienced architects, developers, writers, and testers. We work openly with the developer community and industry experts, on every project, to ensure that some of the best minds in the industry have contributed to and reviewed the guidance as it is being developed. We also love our role as the bridge between the real world needs of our customers and the wide range of products and technologies that Microsoft provides. This guide provides everything you need to get started with Prism and to use it to create fl exible, maintainable Windows Presentation Foundation (WPF) and Microsoft Silverlight ® 4.0 applications. It can be challenging to design and build WPF or Silverlight client applications that are fl exible, maintainable, and that can evolve over time based on changing require- ments. These kinds of applications require a loosely coupled modular architecture that allows individual parts of the application to be independently developed and tested, allowing the application to be modifi ed or extended later on. Additionally, the architecture should promote testability, code re-use, and fl exibility. Prism helps you to design and build fl exible and maintainable WPF and Silverlight applications by using design patterns that support important architectural design principles, such as separation of concerns and loose coupling. This guide helps you understand these design patterns and describes how you can use Prism to imple- ment them in your WPF or Silverlight applications. This guide will show you how to use Prism to implement the Model-View-View- Model (MVVM) pattern in your application, and how to use it along with com- mands and interaction requests to encapsulate application logic and make it test- able. It will show you how to split an application into separate functional modules that can communicate through loosely coupled events, and how to integrate those modules into the overall application. It will show you how to dynamically construct a fl exible user interface by using regions, and how to implement rich naviga- tion across a modular application. Prism allows you to use these design patterns together or in isolation, depending on your particular application requirements. D E V E L O P E R ’ S G U I D E T O M I C R O S O F T ® P R I S M 4 Building Modular MVVM Applications using Windows ® Presentation Foundation and Microsoft Silverlight ® Bob Brumfi eld Geoff Cox David Hill Brian Noyes Michael Puleio Karl Shiffl ett FPO www.it-ebooks.info ’    ®   www.it-ebooks.info www.it-ebooks.info ’   Microsoft ® Prism 4 Building Modular MVVM Applications using Windows ® Presentation Foundation and Microsoft Silverlight ® Bob Brumfield Geoff Cox David Hill Brian Noyes Michael Puleio Karl Shifflett www.it-ebooks.info ISBN: 9780735656109 This document is provided “as-is”. Information and views expressed in this document, including URL and other Internet Web site references, may change without notice. You bear the risk of using it. Some examples depicted herein are provided for illustration only and are fictitious.No real association or connection is intended or should be inferred. © 2011 Microsoft. All rights reserved. Microsoft, Windows, Windows Server, Windows Vista, Silverlight, Expression Blend, MSDN, IntelliSense, Visual C#, Visual C++, and Visual Studio are trademarks of the Microsoft group of companies. All other trademarks are the property of their respective owners. www.it-ebooks.info Contents        xiii The Prism 4 Development Team  xv Ward Bell  xvii Brian Noyes 1 Introduction  Why Use Prism?  Client Application Development Challenges  The Composite Approach  Challenges Not Addressed by Prism  Getting Started with Prism  Prerequisites  Installing Prism  Step 1: Install System Requirements  Step 2: Extract the Prism Source Code, Binaries, and Documentation  Step 3: Register the Prism Binaries  Exploring Prism  What’s New in This Release  What’s Included  Exploring the Documentation  Exploring the QuickStarts  Exploring the Reference Implementations  Upgrading from Earlier Releases  An Overview of Prism  Prism Design Goals  Prism Key Concepts  www.it-ebooks.info Using Prism  Defining the Shell  Creating the Bootstrapper  Creating a Module  Adding a Module View to the Shell  More Information  Community  What Is a Bootstrapper?  2 Initializing Prism Applications  Dependency Injection  Creating the Shell  Key Decisions  Core Scenarios  Creating a Bootstrapper for Your Application  Implementing the CreateShell Method  Implementing the InitializeShell Method  Creating and Configuring the Module Catalog  Creating and Configuring the Container  Core Services  Application-Specific Services  Creating and Configuring the Container in the UnityBootstrapper  Creating and Configuring the Container in the MefBootstrapper  More Information  3 Managing Dependencies Between Components  Key Decision: Choosing a Dependency Injection Container  Considerations for Using the Container  Core Scenarios  Registering Types and Objects  Registering Types with the Unity Container  Registering Types with MEF  Resolving Types and Objects  Resolving Instances with Unity  Resolving Instances with MEF  Using Dependency Injection Containers and Services in Prism  Using IServiceLocator  Considerations for Using IServiceLocator  More Information  4 Modular Application Development  Benefits of Building Modular Applications  Prism’s Support for Modular Application Development  Core Concepts  IModule: The Building Block of Modular Applications  Module Lifetime  www.it-ebooks.info Module Catalog  Controlling When to Load a Module  Integrating Modules with the Application  Communication Between Modules  Dependency Injection and Modular Applications  Key Decisions  Partitioning an Application into Modules  Determining the Ratio of Projects to Modules  .xap File and Module Factoring  Using Dependency Injection for Loose Coupling  Core Scenarios  Defining a Module  Registering and Discovering Modules  Using Code to Register Modules  Using a XAML File to Register Modules  Using a Configuration File to Register Modules  Discovering Modules in a Directory  Loading Modules  Initializing Modules  Specifying Module Dependencies  Specifying Dependencies in Code  Specifying Dependencies in XAML  Specifying Dependencies in a Configuration File  Loading Modules on Demand  Specifying On-Demand Loading in Code  Specifying On-Demand Loading in XAML  Specifying On-Demand Loading in a Configuration File  Requesting On-Demand Loading of a Module  Downloading Remote Modules in the Background  Preparing a Module for Remote Download  Tracking Download Progress  Detecting When a Module Has Been Loaded  Modules in MEF  Using MEF to Register Modules Programmatically  Using MEF to Discover Modules in a Directory  Using MEF to Specify Dependencies in Code  Using MEF to Specify On-Demand Loading  Using MEF to Prepare a Module for Remote Download  More Information  Class Responsibilities and Characteristics  5 Implementing the MVVM Pattern  The View Class  The View Model Class  The Model Class  www.it-ebooks.info Class Interactions  Data Binding  Implementing INotifyPropertyChanged  Implementing INotifyCollectionChanged  Implementing ICollectionView  Commands  Implementing Command Objects  Invoking Command Objects from the View  Invoking Command Methods from the View  Data Validation and Error Reporting  Implementing IDataErrorInfo  Implementing INotifyDataErrorInfo  Construction and Configuration  Creating the View Model Using XAML  Creating the View Model Programmatically  Creating a View Defined as a Data Template  Key Decisions  More Information  Commands  6 Advanced MVVM Scenarios  Composite Commands  Registering and Unregistering Child Commands  Executing Commands in Active Child Views  Commands Within Collections  Command Behaviors  Extending Prism Command Behaviors  Handling Asynchronous Interactions  Retrieving Data and Interacting with Web Services  User Interaction Patterns  Using an Interaction Service  Using Interaction Request Objects  Initiating Interaction Requests from the View Model  Using Behaviors to Implement the Interaction User Experience  Advanced Construction and Configuration  Using MEF to Create the View and View Model  Using Unity to Create the View and View Model  Using an External Class to Create the View and View Model  Testing MVVM Applications  Testing INotifyPropertyChanged Implementations  Testing Simple Cases  Testing Computed and Non-Settable Properties  Testing Whole Object Notifications www.it-ebooks.info Testing INotifyDataErrorInfo Implementations  Testing Validation Rules  Testing the Requirements for INotifyDataErrorInfo Implementations  Testing Asynchronous Service Calls  More Information  7 Composing the User Interface  UI Layout Concepts  Shell  Views  Composite Views  Views and Design Patterns  Commands, UI Triggers, Actions, and Behaviors  Data Binding  Regions  Region Manager  Region Implementation  Default Region Functionality  Extending the Region Implementation  View Composition  View Discovery  View Injection  Navigation  When to Use View Discovery vs. View Injection  UI Layout Scenarios  Implementing the Shell  Stock Trader RI Shell  Defining Regions  Stock Trader RI Shell Regions  IRegion  Using XAML to Add a Region  Using Code to Add a Region  Displaying Views in a Region When the Region Loads  Displaying Views in a Region Programmatically  Navigation  Ordering Views in a Region  Sharing Data Between Multiple Regions  Creating Multiple Instances of a Region  Creating Views  User Controls  Custom Controls  Data Templates  Resources  www.it-ebooks.info [...]... 238 239 239 239 240 240 241 c prism library 243 244 245 246 246 247 247 index 249 Adapter Application Controller Pattern Command Pattern Composite and Composite View Dependency Injection Pattern Event Aggregator Pattern Façade Pattern Inversion of Control Pattern Observer Pattern Presentation Model Pattern Registry Pattern Repository Pattern Separated Interface and Plug-In Service Locator Pattern More... Design-Time Properties Guidelines for Design-Time Sample Data Using Design-Time Sample Data Sample Data Sources UI Layout Key Decisions More Information 149 149 149 151 151 152 152 153 1 54 1 54 155 156 156 157 160 161 161 1 64 1 64 8 Navigation 167 168 168 169 170 172 173 1 74 176 178 180 181 182 186 187 188 190 9 Communication Between Loosely Coupled Components 191 192 193 193 1 94 1 94 Navigation in Prism State-Based... binaries, you will need to manually set a file reference to the Prism Library binaries in your projects The Prism Library signed assemblies will be placed in the following folders: • {prism} \Bin\Desktop • {prism} \Bin\Silverlight • {prism} \Bin\Phone To register the Prism Library binaries, run the RegisterPrismBinaries.bat batch file located in the folder where you extracted Prism This batch file creates... community on the right way to build apps I learned a ton in the process and hopefully contributed something that helped make Prism a better product So, naturally I was delighted when I got the chance to work closely with the team again on the release of Prism 4 Prism 4 offers many things to many people One of the biggest misconceptions is that because it offers so much, it is too big or too complicated for... by Prism Appendix B, “Patterns in the Prism Library.” This appendix describes the software design patterns applied in the Prism Library and the Stock Trader RI This topic primarily targets architects and developers who want to become familiar with the patterns used to address the challenges in building composite applications Appendix C, Prism Library.” This appendix provides an overview of the Prism. .. Silverlight version 4, and includes new guidance related to the Model-View-ViewModel (MVVM) pattern, navigation, and the Managed Extensibility Framework (MEF) Because Prism is built on the NET Framework 4 (which includes WPF) and Silverlight 4, familiarity with these technologies is useful for evaluating and adopting Prism It should be noted that, while Prism is not difficult to learn, developers must... Edition and the Prism Library to develop Prism applications If you are developing Silverlight applications, you need to install the following: • Microsoft Silverlight 4 Tools for Visual Studio 2010 (required for Silverlight development; this includes the developer Silverlight runtime) Note: Although the Silverlight Tools for Visual Studio 2010 are not required, all WPF and Silverlight developers should... Silverlight • Windows Phone Developer Tools SDK For Windows Phone 7 development Note: For more information about using Prism on Windows Phone 7, see the Windows Phone 7 Developer Guide community site on CodePlex Step 2: Extract the Prism Source Code, Binaries, and Documentation To install the Prism assets, right-click the Prismv4.exe file, and then click Run as administrator This will extract the source... like Prism 4 to keep you from being overwhelmed by the complexity and the volume of code that can result from not basing your app on well-defined design patterns and thoroughly tested code to help you implement those patterns This book is another new feature of Prism 4 Previous releases provided great documentation in a standard Help format, consisting of many short topics with links to related topics... Studio Exploring Prism Now that you have successfully installed Prism, it’s time to see what it includes This section provides a brief overview of the various elements included in Prism, including the Prism Library, documentation, and the various QuickStarts and reference implementations What’s New in This Release This release of Prism has been updated to target WPF 4 and Silverlight 4, and it contains . • • • • • • • • • • • • • SPINE= .4 DEVELOPER’S GUIDE TO MICROSOFT ® PRISM 4 DEVELOPER’S GUIDE TO MICROSOFT ® PRISM 4 For more information explore: msdn .microsoft. com/practices Software Architecture. needs of our customers and the wide range of products and technologies that Microsoft provides. This guide provides everything you need to get started with Prism and to use it to create fl exible,. This guide helps you understand these design patterns and describes how you can use Prism to imple- ment them in your WPF or Silverlight applications. This guide will show you how to use Prism to

Ngày đăng: 28/04/2014, 15:55

Từ khóa liên quan

Mục lục

  • Copyright

  • Contents

  • The Team Who Brought YouThis Guide

  • Foreword

  • Foreword

  • Chapter 1. Introduction

    • Why Use Prism?

    • Getting Started with Prism

    • An Overview of Prism

    • More Information

    • Chapter 2. Initializing Prism Applications

      • What Is a Bootstrapper?

      • Key Decisions

      • Core Scenarios

      • More Information

      • Chapter 3. Managing Dependencies Between Components

        • Key Decision: Choosing a Dependency Injection Container

        • Core Scenarios

        • Using Dependency Injection Containers and Services in Prism

        • Using IServiceLocator

        • More Information

        • Chapter 4. Modular Application Development

          • Benefits of Building Modular Applications

          • Core Concepts

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan