How to add new tab(or view) to AnimatedTabControl in StockTraderRI WPF ?

Topics: Prism v4 - WPF 4
Mar 8, 2011 at 7:25 PM
Edited Mar 8, 2011 at 7:26 PM

Can someone list the steps of how to add a new tab to the AnimatedTabControl in StockTraderRI (WPF) ? Even just to add an empty/blank new view(tab). I created a new view (with module etc) that I want to display as a new tab but I seem to be missing some step that I can't see to register the view. Can someone list the steps even to add a blank tab/view so I can check if I missed something ?

Much appreciated


Mar 9, 2011 at 9:41 AM
Edited Mar 9, 2011 at 1:56 PM

Just to be clearer on what I'm doing: I'm adding a new model+view to the StockTrader MainRegion (i.e. a new tab). I thought it was simply a matter of registering my new module in the StockTraderRIBootStrapper as follows:

this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(NewModule).Assembly));

And use declarative attributes on the module's View class to register/associate the view with MainRegion so it can be discovered at runtime

[ViewExport(RegionName = RegionNames.MainRegion)]
public partial class NewModuleView : UserControl

But while the module does initialise, the view is not being discovered by the ImportMany in AutoPopulateExportedViewsBehavior in the StockTraderRI InfraStructure library. Debugging tells me that RegisteredViews filled by the following ImportMany is not populating with my new view.

[ImportMany(AllowRecomposition = true)]
public Lazy<object, IViewRegionRegistration>[] RegisteredViews { get; set; }

What am I missing? Or how can I debug further? I don't know how to get inside RegisteredViews to debug how its being populated

Mar 9, 2011 at 4:50 PM

Hi Gary,

Following the approach described in this thread, the views that are placed inside the AnimatedTabControl must have a HeaderInfo property defined inside the View Model, as it is done in the PositionSummaryView.

You might find the TabItemResource.xaml file inside the Resources folder of the StockTraderRI project useful to clarify more about this.

I hope you find this helpful.

Guido Leandro Maliandi

Mar 9, 2011 at 5:25 PM

Hi Guido,

Yes, I have the HeaderInfo property defined as you describe already. It would probably throw an error if I didn't have it defined?

At the moment this is looking like an MEF composition discovery problem as the [ImportMany] is not discovering the View that I marked with the [ViewExport] attribute. This kind of thing seems to be not uncommon with MEF according to this guide:

Any other ideas? I'm working through the MEF debugging & diagnostics steps at the moment:

Has anyone successfully added another tab to the StockTraderRI? (just to confirm it does work - that would at least tell me it is my code rather than any bug in StockTraderRI)


Mar 9, 2011 at 5:36 PM


In that case, you should confirm whether your module is being correctly loaded. I was able to add a custom view to the MainRegion in the StockTraderRI (which is an AnimatedTabControl) by using the ViewExport attribute, but I have defined the HeaderInfo property in the ViewModel. If the property is defined in the view, then I had to add the following line in the view's constructor in order for it to work:

this.DataContext = this;
On the other hand, if I omitted that property, no error was thrown; the view was added but the header for the tab was empty, so there was a "blank space" in the tab control's header, which sent me to that view if I clicked it.

I hope you find this helpful.

Guido Leandro Maliandi

Mar 9, 2011 at 7:11 PM


Thats great to hear! If I could even get a "blank space" tab, I could work out the rest. Can you share what route/steps you took to build the blank tab? Did you start with blank class library project/files? Or copy existing module project or files? etc.

i.e. tell me how to recreate the steps you took.

Many thanks,


Mar 10, 2011 at 9:24 AM


good news: I got it working. After you said you had no issue, I started again with a very basic almost "empty" module and built up the classes again and it worked. The only signifigant change between it and the previous version was the XAML code. I think something in my previous view XAML was the cause.

Thank you for your help