Reference implementation MainToolbar data source

Topics: Prism v2 - WPF 3.5
Sep 16, 2009 at 9:34 AM

Hi all,

I'm relatively new to WPF and have been looking through the Stock Trader Reference Implementation and cannot for the life of me figure out how MainToolbar gets it's data source. It's clearly somehow bound to modules but I can't see where that is happening.

Anyone care to solve that mystery for me?



Sep 17, 2009 at 7:48 PM
Edited Sep 17, 2009 at 7:49 PM

Hi Rich,

You can check the WatchModule class located in the WatchList module, which uses View Discovery to register the view in the region in its Initialize() method.

Please let me know if this helps.

Damian Schenkelman


Sep 22, 2009 at 9:09 AM

Ah, that makes sense now. Thanks Damian!

Oct 6, 2010 at 3:37 PM
Edited Oct 7, 2010 at 1:43 PM

I have been trying to figure this out as well. What I can't understand is: What is contained in the MainToolbar? I only see two buttons labeled "POSITIONS" and "WATCH LIST". Are these two buttons contained in the MainToolbar?

This code is in the WatchModule.cs:

public void Initialize()
            this.regionManager.RegisterViewWithRegion(RegionNames.MainToolBarRegion, () => this.addWatchPresenter.View);

And this code is in the PositionModule.cs:

public void Initialize()
            this.regionManager.RegisterViewWithRegion(RegionNames.ResearchRegion, () => this.positionPieChartPresentationModel.View);
            this.regionManager.RegisterViewWithRegion(RegionNames.MainRegion, () => this.positionSummaryPresentationModel.View);

When doing a global Find, there is no place where the PositionModule is added to the MainToolBar.

Where exactly in the code are "POSITIONS" and "WATCH LIST" added? I tried stepping through the code above but was unable to find this.

What I would like to do is create a new module and a new button to launch the module.

Oct 7, 2010 at 6:21 PM


The view which is added to the Main Toolbar is named AddWatchView.xaml. This view contains the text box that allows you to add symbols to the WatchList.

Regarding to where the “POSITION” and “WATCH LIST” texts are added, you could check the following locations:

  1. PositionSummaryPresentationModel.cs (line 61)
  2. WatchListPresentationModel.cs (line 47)

Both of them are returned in the HeaderInfo property of the aforementioned classes.

Hope this helps.

Fernando Antivero