Compartir a través de


Technical Challenges

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The Stock Trader Reference Implementation (Stock Trader RI) demonstrates how you can address common technical challenges that you face when you build composite applications in Windows Presentation Foundation (WPF). The following table describes the technical challenges that the Stock Trader RI addresses.

Technical challenge

Feature in Stock Trader RI

Example of where feature is demonstrated

Views and composite UI

Regions: The use of regions for placing the views without having to know how the layout is implemented.


Regions defined in the Shell and Position module Orders view. Position, Watch, and News module initializers adding content to regions.

StockTraderRI\Shell.xaml

StockTraderRI.Modules.Position\Orders\OrdersView.xaml

StockTraderRI.Modules.Position\PositionModule.cs

StockTraderRI.Modules.Position\Controllers\OrdersController.cs

StockTraderRI.Modules.Watch\WatchModule.cs

StockTraderRI.Modules.News\Controllers\NewsController.cs

Composite view: Shows how a composite view communicates with its child view.

The line chart is nested inside the composite view. See the line chart corresponding to a stock.

StockTraderRI.Modules.Position\PositionSummary\PositionSummaryPresentationModel.cs

StockTraderRI.Modules.Market\TrendLine\TrendLinePresenter.cs

Order screen

StockTraderRI.Modules.Position\Orders\OrderCompositePresentationModel.cs

StockTraderRI.Modules.Position\Orders\OrderDetailsPresentationModel.cs

StockTraderRI.Modules.Position\Orders\OrderCommandsView.xaml.cs

StockTraderRI.Modules.Position\Controllers\OrdersController.cs

Compose UI across modules: The watch module has a view and also is a part of the toolbar.

Add a stock to the watch list

StockTraderRI.Modules.Watch\AddWatchView.xaml

StockTraderRI.Modules.Watch\WatchList\WatchListView.xaml

Decoupled communication

Commands: Shows the Command pattern. The command to buy or sell a stock is a delegate command. This command uses the same command instance but with a different parameter corresponding to the stock. This decouples the invoker from the receiver and shows passing additional data with the command.

Buy and Sell command invokers in PositionGrid and handlers in OrdersController

StockTraderRI.Modules.Position\Controllers\OrdersController.cs

StockTraderRI.Modules.Position\PositionGrid.xaml



Composite commands: Use composite commands to broadcast all of the commands. The Submit All or Cancel All commands execute all of the individual instances of the Submit or Cancel commands.

Submit All and Cancel All buttons

StockTraderRI.Infrastructure\StockTraderRICommands.cs

StockTraderRI.Modules.Position\Orders\OrderDetailsPresentationModel.cs

StockTraderRI.Modules.Position\Controllers\OrdersController.cs

Active aware commands: Use active aware commands to determine the target model for the command depending on which view is currently active.

Submit and Cancel buttons

StockTraderRI.Infrastructure\StockTraderRICommands.cs

StockTraderRI.Modules.Position\Orders\OrderDetailsPresentationModel.cs

StockTraderRI.Modules.Position\Controllers\OrdersController.cs

Event Aggregator pattern: Publish and Subscribe to events across decoupled modules. Publisher and Subscriber have no contract other than the event type.

Show relevant news content: When the user selects a position in the position list, the communication to the news module uses the EventAggregator service.

StockTraderRI.Modules.Position\PositionSummary\PositionSummaryPresentationModel.cs

StockTraderRI.Modules.News\Controllers\NewsController.cs

Market feed updates: The consumers of the market feed service subscribe to an event to be notified when new feeds are available and the consumers then update the model behind the UI.

StockTraderRI.Modules.Market\Services\MarketFeedService.cs

StockTraderRI.Modules.Position\PositionSummary\PositionSummaryPresentationModel.cs

StockTraderRI.Modules.WatchList\WatchList\WatchListPresentationModel.cs

Services: Services are also used to communicate between modules. Services are more contractual and flexible than commands.

Several service implementations in module assemblies

Services:

StockTraderRI.Modules.Market\Services\MarketFeedService.cs

StockTraderRI.Modules.Market\Services\MarketHistoryService.cs

StockTraderRI.Modules.News\Services\NewsFeedService.cs

StockTraderRI.Modules.Watch\Services\WatchListService.cs

StockTraderRI.Modules.Position\Services\AccountPositionService.cs

StockTraderRI.Modules.Position\Services\XmlOrdersService.cs

Other technical challenges

WPF: Use WPF for the user interface

Shell and Module views

The starting point for Stock Trader RI is in the StockTraderRI\App.xaml\App.xaml.cs

Bootstrapper: The use of a bootstrapper to initialize the application with global services.

Created bootstrapper with the Unity DI container and configuring global services, such as logging and module enumeration.

Bootstrapper:

StockTraderRI\StockTraderRIBootstrapper.cs

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.