Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Developer’s Guide to Microsoft® Prism 4: Building Modular MVVM Applications using Windows® Presentation Foundation and Microsoft Silverlight®
The Team Who Brought You This Guide
The Prism 4 Development Team
Foreword
Foreword
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
Using Prism
Defining the Shell
Creating the Bootstrapper
Creating a Module
Adding a Module View to the Shell
More Information
Community
2. Initializing Prism Applications
What Is a Bootstrapper?
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
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
5. Implementing the MVVM Pattern
Class Responsibilities and Characteristics
The View Class
The View Model Class
The Model Class
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
6. Advanced MVVM Scenarios
Commands
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
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
Commands
UI Triggers, Actions, and Behaviors
Data Binding
Regions
Region Manager
Region Implementation
Module User Control to Region Mapping
Default Region Functionality
Region Adapter
Region Behaviors
Registration Behavior
Auto-Population Behavior
Region Context Behaviors
Activation Behavior
Region Lifetime Behavior
Control-Specific Behaviors
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
Application Resources
Module Resources
Control Resources
UI Design Guidance
Guidelines for Designing User Interfaces
Container Composition
Viewing Composite Application at Design Time
Layout
Animation
Run-Time Optimization
Design-Time Optimizations
Large Solutions with Many XAML Resources
XAML Assets
Visual Designers and Referenced Assemblies
Silverlight Design-Time App.xaml Resources
Guidelines for Creating Designer Friendly Views
Coding for Design Time
Mitigating Problems in Design-Time User Code
Understanding when User Control Code Executes at Design-Time
Design-Time Properties
d:DataContext Property
d:DesignInstance Markup Extension
Typical d:DataContext Scenario
Guidelines for Design-Time Sample Data
Using Design-Time Sample Data
Sample Data Sources
Expression Blend XML Sample Data
Expression Blend 4 and Visual Studio 2010 XAML Sample Data
XAML Resource
Code
UI Layout Key Decisions
More Information
8. Navigation
Navigation in Prism
State-Based Navigation
Displaying Data in Different Formats or Styles
Reflecting Application State
Interacting with the User
View-Based Navigation
Prism Region Overview
Basic Region Navigation
View and View Model Participation in Navigation
Passing Parameters During Navigation
Navigating to Existing Views
Confirming or Canceling Navigation
Using the Navigation Journal
Using the WPF and Silverlight Navigation Frameworks
The Region Navigation Sequence
More Information
9. Communication Between Loosely Coupled Components
Commanding
Creating a Delegate Command
Creating a Composite Command
Making a Command Globally Available
Binding to a Globally Available Command
Region Context
Shared Services
Event Aggregation
IEventAggregator
CompositePresentationEvent
Creating and Publishing Events
Creating an Event
Publishing an Event
Subscribing to Events
Subscribing on the UI Thread
Subscription Filtering
Subscribing Using Strong References
Default Subscriptions
Unsubscribing from an Event
More Information
10. Sharing Code Between Silverlight and WPF
Goal and Benefits
Out of Scope
Multi-Targeting Scenarios
Multi-Targeted Considerations
Multi-Targeted Elements
A Solution to Multi-Targeting: Multiple Linked Projects
Core Application
Creating Multi-Targeted Applications
Design and Code Guidelines
Use Separated Presentation Patterns to Maximize the Amount of Shared Code
Write Code So That It Compiles on Both Platforms
Use #if statements if you have simple or single line constructs
Use partial classes if most of the class is similar but some methods have platform-specific implementations
Use partial methods only if you need to call an extra method on one platform but not the other
Build platform-specific classes with a single responsibility
Create a Solution Folder for Silverlight and Another for WPF
Check Silverlight and WPF References When Refactoring Code
Process Guidelines
Develop the Core Application in Silverlight
Link the Shared Code Between the Source Project and the Target Project
Use the Same Namespace for Silverlight and WPF Projects
Team Build Guidelines
Configure Team Build to Build in Place
Contrasting Silverlight and WPF
Silverlight and WPF Architectural Overview
Differences Between Silverlight and WPF
Resources
Triggers
Data Binding
Commanding
Miscellaneous
More Information
11. Deploying Prism Applications
Deploying Silverlight Prism Applications
Packaging Prism Modules as .xap Files
Reducing the Download Size of Module .xap Files
Preparing a Web Server to Host Silverlight Applications
Deploying the Application
Deploying WPF Prism Applications
Deploying WPF Prism Application with ClickOnce
ClickOnce Publishing Process
ClickOnce Deployment and Update Process
More Information
A. Glossary
B. Patterns in the Prism Library
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 Information
C. Prism Library
Registering with Visual Studio 2010
Organization of the Prism Library
The Prism Library Source
Modifying the Library
Running the Tests
More Information
Index
About the Authors
← Prev
Back
Next →
← Prev
Back
Next →