You are previewing Developer’s Guide to Microsoft® Prism 4: Building Modular MVVM Applications with Windows® Presentation Foundation and Microsoft Silverlight®.
O'Reilly logo
Developer’s Guide to Microsoft® Prism 4: Building Modular MVVM Applications with Windows® Presentation Foundation and Microsoft Silverlight®

Book Description

This guide provides everything you need to get started with Prism and to use it to create flexible, maintainable Windows® Presentation Foundation (WPF) and Silverlight 4.0 applications.

Table of Contents

  1. Developer’s Guide to Microsoft® Prism 4: Building Modular MVVM Applications using Windows® Presentation Foundation and Microsoft Silverlight®
  2. The Team Who Brought You This Guide
    1. The Prism 4 Development Team
  3. Foreword
  4. Foreword
  5. 1. Introduction
    1. Why Use Prism?
      1. Client Application Development Challenges
      2. The Composite Approach
      3. Challenges Not Addressed by Prism
    2. Getting Started with Prism
      1. Prerequisites
      2. Installing Prism
        1. Step 1: Install System Requirements
        2. Step 2: Extract the Prism Source Code, Binaries, and Documentation
        3. Step 3: Register the Prism Binaries
      3. Exploring Prism
        1. What’s New in This Release
        2. What’s Included
        3. Exploring the Documentation
        4. Exploring the QuickStarts
        5. Exploring the Reference Implementations
      4. Upgrading from Earlier Releases
    3. An Overview of Prism
      1. Prism Design Goals
      2. Prism Key Concepts
      3. Using Prism
        1. Defining the Shell
        2. Creating the Bootstrapper
        3. Creating a Module
        4. Adding a Module View to the Shell
    4. More Information
      1. Community
  6. 2. Initializing Prism Applications
    1. What Is a Bootstrapper?
      1. Dependency Injection
      2. Creating the Shell
    2. Key Decisions
    3. Core Scenarios
      1. Creating a Bootstrapper for Your Application
        1. Implementing the CreateShell Method
        2. Implementing the InitializeShell Method
      2. Creating and Configuring the Module Catalog
      3. Creating and Configuring the Container
        1. Core Services
        2. Application-Specific Services
        3. Creating and Configuring the Container in the UnityBootstrapper
        4. Creating and Configuring the Container in the MefBootstrapper
    4. More Information
  7. 3. Managing Dependencies Between Components
    1. Key Decision: Choosing a Dependency Injection Container
      1. Considerations for Using the Container
    2. Core Scenarios
      1. Registering Types and Objects
        1. Registering Types with the Unity Container
        2. Registering Types with MEF
      2. Resolving Types and Objects
        1. Resolving Instances with Unity
        2. Resolving Instances with MEF
    3. Using Dependency Injection Containers and Services in Prism
    4. Using IServiceLocator
      1. Considerations for Using IServiceLocator
    5. More Information
  8. 4. Modular Application Development
    1. Benefits of Building Modular Applications
      1. Prism’s Support for Modular Application Development
    2. Core Concepts
      1. IModule: The Building Block of Modular Applications
      2. Module Lifetime
      3. Module Catalog
      4. Controlling When to Load a Module
      5. Integrating Modules with the Application
      6. Communication Between Modules
      7. Dependency Injection and Modular Applications
    3. Key Decisions
      1. Partitioning an Application into Modules
        1. Determining the Ratio of Projects to Modules
        2. .xap File and Module Factoring
      2. Using Dependency Injection for Loose Coupling
    4. Core Scenarios
      1. Defining a Module
      2. Registering and Discovering Modules
        1. Using Code to Register Modules
        2. Using a XAML File to Register Modules
        3. Using a Configuration File to Register Modules
        4. Discovering Modules in a Directory
      3. Loading Modules
      4. Initializing Modules
      5. Specifying Module Dependencies
        1. Specifying Dependencies in Code
        2. Specifying Dependencies in XAML
        3. Specifying Dependencies in a Configuration File
      6. Loading Modules on Demand
        1. Specifying On-Demand Loading in Code
        2. Specifying On-Demand Loading in XAML
        3. Specifying On-Demand Loading in a Configuration File
        4. Requesting On-Demand Loading of a Module
      7. Downloading Remote Modules in the Background
        1. Preparing a Module for Remote Download
        2. Tracking Download Progress
      8. Detecting When a Module Has Been Loaded
      9. Modules in MEF
        1. Using MEF to Register Modules Programmatically
        2. Using MEF to Discover Modules in a Directory
        3. Using MEF to Specify Dependencies in Code
        4. Using MEF to Specify On-Demand Loading
        5. Using MEF to Prepare a Module for Remote Download
    5. More Information
  9. 5. Implementing the MVVM Pattern
    1. Class Responsibilities and Characteristics
      1. The View Class
      2. The View Model Class
      3. The Model Class
    2. Class Interactions
      1. Data Binding
        1. Implementing INotifyPropertyChanged
        2. Implementing INotifyCollectionChanged
        3. Implementing ICollectionView
      2. Commands
        1. Implementing Command Objects
        2. Invoking Command Objects from the View
        3. Invoking Command Methods from the View
      3. Data Validation and Error Reporting
        1. Implementing IDataErrorInfo
        2. Implementing INotifyDataErrorInfo
    3. Construction and Configuration
      1. Creating the View Model Using XAML
      2. Creating the View Model Programmatically
      3. Creating a View Defined as a Data Template
    4. Key Decisions
    5. More Information
  10. 6. Advanced MVVM Scenarios
    1. Commands
      1. Composite Commands
        1. Registering and Unregistering Child Commands
        2. Executing Commands in Active Child Views
      2. Commands Within Collections
      3. Command Behaviors
        1. Extending Prism Command Behaviors
    2. Handling Asynchronous Interactions
      1. Retrieving Data and Interacting with Web Services
    3. User Interaction Patterns
      1. Using an Interaction Service
      2. Using Interaction Request Objects
        1. Initiating Interaction Requests from the View Model
        2. Using Behaviors to Implement the Interaction User Experience
    4. Advanced Construction and Configuration
      1. Using MEF to Create the View and View Model
      2. Using Unity to Create the View and View Model
      3. Using an External Class to Create the View and View Model
    5. Testing MVVM Applications
      1. Testing INotifyPropertyChanged Implementations
        1. Testing Simple Cases
        2. Testing Computed and Non-Settable Properties
        3. Testing Whole Object Notifications
      2. Testing INotifyDataErrorInfo Implementations
        1. Testing Validation Rules
        2. Testing the Requirements for INotifyDataErrorInfo Implementations
      3. Testing Asynchronous Service Calls
    6. More Information
  11. 7. Composing the User Interface
    1. UI Layout Concepts
      1. Shell
      2. Views
        1. Composite Views
        2. Views and Design Patterns
        3. Commands, UI Triggers, Actions, and Behaviors
          1. Commands
          2. UI Triggers, Actions, and Behaviors
        4. Data Binding
      3. Regions
        1. Region Manager
        2. Region Implementation
          1. Module User Control to Region Mapping
        3. Default Region Functionality
          1. Region Adapter
          2. Region Behaviors
          3. Registration Behavior
          4. Auto-Population Behavior
          5. Region Context Behaviors
          6. Activation Behavior
          7. Region Lifetime Behavior
          8. Control-Specific Behaviors
        4. Extending the Region Implementation
      4. View Composition
        1. View Discovery
        2. View Injection
        3. Navigation
        4. When to Use View Discovery vs. View Injection
    2. UI Layout Scenarios
      1. Implementing the Shell
        1. Stock Trader RI Shell
      2. Defining Regions
        1. Stock Trader RI Shell Regions
        2. IRegion
        3. Using XAML to Add a Region
        4. Using Code to Add a Region
      3. Displaying Views in a Region When the Region Loads
      4. Displaying Views in a Region Programmatically
        1. Navigation
      5. Ordering Views in a Region
      6. Sharing Data Between Multiple Regions
      7. Creating Multiple Instances of a Region
      8. Creating Views
        1. User Controls
        2. Custom Controls
        3. Data Templates
        4. Resources
          1. Application Resources
          2. Module Resources
          3. Control Resources
    3. UI Design Guidance
      1. Guidelines for Designing User Interfaces
        1. Container Composition
        2. Viewing Composite Application at Design Time
        3. Layout
        4. Animation
        5. Run-Time Optimization
        6. Design-Time Optimizations
          1. Large Solutions with Many XAML Resources
          2. XAML Assets
          3. Visual Designers and Referenced Assemblies
        7. Silverlight Design-Time App.xaml Resources
      2. Guidelines for Creating Designer Friendly Views
        1. Coding for Design Time
        2. Mitigating Problems in Design-Time User Code
        3. Understanding when User Control Code Executes at Design-Time
        4. Design-Time Properties
          1. d:DataContext Property
          2. d:DesignInstance Markup Extension
          3. Typical d:DataContext Scenario
      3. Guidelines for Design-Time Sample Data
        1. Using Design-Time Sample Data
        2. Sample Data Sources
          1. Expression Blend XML Sample Data
          2. Expression Blend 4 and Visual Studio 2010 XAML Sample Data
          3. XAML Resource
          4. Code
    4. UI Layout Key Decisions
    5. More Information
  12. 8. Navigation
    1. Navigation in Prism
      1. State-Based Navigation
        1. Displaying Data in Different Formats or Styles
        2. Reflecting Application State
        3. Interacting with the User
      2. View-Based Navigation
        1. Prism Region Overview
        2. Basic Region Navigation
        3. View and View Model Participation in Navigation
        4. Passing Parameters During Navigation
        5. Navigating to Existing Views
        6. Confirming or Canceling Navigation
        7. Using the Navigation Journal
        8. Using the WPF and Silverlight Navigation Frameworks
        9. The Region Navigation Sequence
    2. More Information
  13. 9. Communication Between Loosely Coupled Components
    1. Commanding
      1. Creating a Delegate Command
      2. Creating a Composite Command
      3. Making a Command Globally Available
      4. Binding to a Globally Available Command
    2. Region Context
    3. Shared Services
    4. Event Aggregation
      1. IEventAggregator
      2. CompositePresentationEvent
      3. Creating and Publishing Events
        1. Creating an Event
        2. Publishing an Event
      4. Subscribing to Events
        1. Subscribing on the UI Thread
        2. Subscription Filtering
        3. Subscribing Using Strong References
        4. Default Subscriptions
        5. Unsubscribing from an Event
    5. More Information
  14. 10. Sharing Code Between Silverlight and WPF
    1. Goal and Benefits
    2. Out of Scope
    3. Multi-Targeting Scenarios
    4. Multi-Targeted Considerations
    5. Multi-Targeted Elements
    6. A Solution to Multi-Targeting: Multiple Linked Projects
      1. Core Application
    7. Creating Multi-Targeted Applications
      1. Design and Code Guidelines
        1. Use Separated Presentation Patterns to Maximize the Amount of Shared Code
        2. Write Code So That It Compiles on Both Platforms
          1. Use #if statements if you have simple or single line constructs
          2. Use partial classes if most of the class is similar but some methods have platform-specific implementations
          3. Use partial methods only if you need to call an extra method on one platform but not the other
          4. Build platform-specific classes with a single responsibility
        3. Create a Solution Folder for Silverlight and Another for WPF
        4. Check Silverlight and WPF References When Refactoring Code
      2. Process Guidelines
        1. Develop the Core Application in Silverlight
        2. Link the Shared Code Between the Source Project and the Target Project
        3. Use the Same Namespace for Silverlight and WPF Projects
      3. Team Build Guidelines
        1. Configure Team Build to Build in Place
      4. Contrasting Silverlight and WPF
        1. Silverlight and WPF Architectural Overview
        2. Differences Between Silverlight and WPF
          1. Resources
          2. Triggers
          3. Data Binding
          4. Commanding
          5. Miscellaneous
    8. More Information
  15. 11. Deploying Prism Applications
    1. Deploying Silverlight Prism Applications
      1. Packaging Prism Modules as .xap Files
      2. Reducing the Download Size of Module .xap Files
      3. Preparing a Web Server to Host Silverlight Applications
      4. Deploying the Application
    2. Deploying WPF Prism Applications
      1. Deploying WPF Prism Application with ClickOnce
        1. ClickOnce Publishing Process
        2. ClickOnce Deployment and Update Process
    3. More Information
  16. A. Glossary
  17. B. Patterns in the Prism Library
    1. Adapter
    2. Application Controller Pattern
    3. Command Pattern
    4. Composite and Composite View
    5. Dependency Injection Pattern
    6. Event Aggregator Pattern
    7. Façade Pattern
    8. Inversion of Control Pattern
    9. Observer Pattern
    10. Presentation Model Pattern
    11. Registry Pattern
    12. Repository Pattern
    13. Separated Interface and Plug-In
    14. Service Locator Pattern
    15. More Information
  18. C. Prism Library
    1. Registering with Visual Studio 2010
    2. Organization of the Prism Library
    3. The Prism Library Source
    4. Modifying the Library
    5. Running the Tests
    6. More Information
  19. Index
  20. About the Authors
  21. Copyright