Patterns for building composite applications using WPF

Source: Internet
Author: User

This article describes the following:

Composite Application Basics

Bootstrapper and Module initialization

Regional and Regionmanager

views, commands, and events
This article uses the following techniques:

WPF Composite Application Guide

Content

Issue: Single Application

Composite applications

Composite Application Guide

Bootstrapper and Containers

Module initialization

Using the bootstrapper

Modules and Services

Regional and Regionmanager

Local Action Area

View

A separate representation

Command

Event

Conclusion

Technologies such as Windows®presentation Foundation (WPF) and silverlight™ provide developers with a simple declarative approach that allows them to quickly and easily develop applications with a rich user experience. However, while these techniques help to further isolate the presentation layer from the logical layer, they cannot solve the old problem of how to build an easily maintainable application.

For smaller projects, developers with experience should be able to design and build applications that are easy to maintain and extend, and this is not an excessive requirement. However, as the number of moving parts (and the people who use them) continues to increase, the difficulty in controlling the project starts to grow exponentially.

A composite application is a solution specifically designed to address this issue. In this article, I'll explain the definition of a composite application and explain how to build a composite application that leverages WPF functionality. I will then introduce you to the new WPF Composite Application Guide (formerly code-named "Prism") from the Microsoft mode and implementation Solutions team.

Issue: Single Application

Let's use an example to understand the requirements of a composite application. Contoso Financial Investments provides an application to manage stock portfolios. With this application, users can view current investments and new projects related to these investments, add new projects to the watch list, and perform purchase/sales transactions.

If you construct a traditional WPF application that has user controls, you should first build a top-level window and add user controls to each of these features. In this case, you need to add the following user controls: Positiongrid, Positionsummary, trendline, and watchlist (see Figure 1). During the design process, individual user controls are arranged in the main window by manual manipulation in XAML or by using a designer such as Expression blend™.

Figure 1 user controls in a single application

Then, you connect all the content using Routedevents, routedcommands, and data binding. For more information about this topic, see Brian Noyes's article in this issue "understanding routed events and commands in WPF" (msdn.microsoft.com/magazine/cc785480). Positiongrid has an associated routedcommand to choose from. In the command's Execute handler, the Tickersymbolselected event occurs whenever a location is selected. Trendline and newsreader are connected to listen for the tickersymbolselected event and render the corresponding content based on the selected ticker symbol.

In this case, the application is tightly coupled with each control. There is a lot of logic in the UI for coordinating the various parts. There is also an interdependence between controls.

Because of these dependencies, there is no easy way to break an application into a form where you can develop separate parts separately. While all user controls can be placed in a separate assembly to improve maintainability, this approach simply shifts the problem from the main application to the control assembly, which is not a cure. In this model, it is very difficult to make major changes or introduce new features.

Now, let's add two new business requirements to make the problem a little more complex. The first requirement is to add a fund bond screen that displays personal bonds about the selected fund when you double-click a fund. The second requirement is to add a new screen that displays a list of hyperlinks associated with the selected fund. Because of time constraints, these features must be developed in parallel by different teams.

Each team develops separate controls: Fundnotes and Fundlinks. To add these two controls to the same control assembly, you must add them to the control project. More importantly, it must be added to the main form, which means that changes to code and XAML in each control must be merged into the main form. Such operations can be very fragile, especially for existing applications.

How do I apply all the changes to the main application? To complete this task, you may need to spend a significant amount of time performing merge and split operations in the source control. If there is an error in applying the change or accidentally overwriting something, the application is compromised. The remedy is to reconsider the application design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.