Looking for advice on loading views into tabregion.

Topics: Prism v4 - Silverlight 4
May 14, 2012 at 6:29 PM

Hi All

I have a RadTabControl as a region in my application for loading settings/lists that will be used throughout my application.

I would like to load the associated view into the RadTabRegion when the user selects an option from a listbox on the left hand side of the screen.

The listbox on the left hand side of the screen pulls all the options from a database and also holds the name of the view I want to navigate to(probably not the best solution but these are pulled from the database based on the users permissions)

There could be over a dozen of these views.  I would like to load all these views into the region but I don't want them visible until I call RegionManager.RequestNavigate(a method will be called in the viewmodel when the user selects an option from the list).

From what I know the options to load the views are:

RegionManager.RegisterViewWithRegion - This will load the view into the region when the region is active, so I don't think I can use this, also I don't think I can use this as I need to use the view name when calling RegionManager.RequestNavigate

Region.Add - I have used this before and it work as I wanted, I could add the view to the region and then deactivate it.  I can't use this as when I try to activate it I get an error that it can't be deactivated in this type of region(RadTabRegion).

I'm stumped at this stage, can anyone think of any else I can try.




May 14, 2012 at 8:06 PM

Hi Paul,

Based on my understanding, the reason behind the exception you are mentioning is that the RadTabControl inherits from an ItemsControl; and therefore, Prism will treat it as an AllActiveRegion by default. In an AllActiveRegion it's not possible to deactivate views and thus the aforementioned exception is thrown. This can be changed by defining your own RegionAdapter for a RadTabControl and registering it overriding the ConfigureRegionAdapterMappings method in your bootstrapper. You can find more information about this in the following section of the Prism documentation:

Regarding your scenario, is there a reason you need to inject all the views in the region even before their are requested by the user? If there is not, you can simply inject the views when needed by performing a NavigationRequest like you mentioned above and you would not need to worry about pre-loading the views and hiding them.


Damian Cherubini

May 15, 2012 at 10:25 AM

Thanks Damian

I always asumed that using RegionManager.RequestNavigate only works if the view is already loaded into the region.  Not sure how I came to this conclusion, maybe I couldn't get it to work at some stage or because its called RequestNavigate and you pass the name of the view, anyway that worked like a charm.

The problem I'm having now is that it shows the RadTabItem but its not selected but I'll have a look at Telerik site and try find a solution.

Thanks again Damian