Switching between Views like in a TabControl

Topics: Prism v1
Jan 20, 2009 at 10:30 PM

First I have to say that I've seen similar questions but none that fits exactly to what I need:

I have a Shell with two regions: TaskBarRegion and MainRegion
The TaskBarRegion is a ItemsControl and the MainRegion is a ContentControl.

I have a couple of Modules loaded during startup where each Module has a View that I want to add to the MainRegion. At the same time I want a Button to be automagically created and added to the TaskBarRegion. The created Button should correspond to the added View and should get its text, a icon, etc. from properties defined in the loaded Module. When the Button is pressed the View should be activated.

The behavior I'm looking for is exactly the same as the behavior of a TabControl where each View loaded into the MainRegion gets its own TabItem.
Of course I could use a TabControl if there was a way of separating the TabItems from the actual Tab-content (think of it as adding tabpages to a TabControl but the tabselectionbuttons should show up in a separate toolbar, menu or something similar instead.)

I've followed the suggested solution from jtango18 and gblock in this thread: Access the shell from modules and sure that works just fine. But for me it seems a little bit strange that each View must implement the ActivateView()-method. I want the Shell to take care of showing/hiding my Views because that's kind of a "core functionality". If a third party developer should develop a module for my system I don't want him to bother about showing the view when a button is clicked. The only thing he should provide specifically for this, is a string for the name of the view (and button) and a icon.

Is the jtango18/gblock-solution the best for this kind of problem or is there a better way of doing it?
Jan 21, 2009 at 2:17 AM
Hi ErikH.

I've been away from CWPF development for a few months but starting to get back into it. I found for myself the easiest solution was to not use a region manager and instead create my own management around a document model. This way the module does not need to know how or where it is being displayed or how many times it's being displayed.

Have a look here at my samples that demonstrate this model http://code.google.com/p/cwpfsamples/.

As mentioned I've been away for a while, I've got to get back into creating more examples of how to solve sole of these use-cases in a fairly straighforward way.
Jan 21, 2009 at 10:34 AM
Hi, and thanks for the reply!

I've looked through your sample and in some sense it does what I'm asking for but I'm actually not interested in opening/closing documents but rather to show/hide views of different modules.

Basically what I want is: Each time a View is added to the MainRegion I want to create a Button with a text and a image in another container in the Shell. The View should have some properties (or attributes) defining a string and a image that the generated button should display. When the button is pressed the corresponding view should be activated and shown in the MainRegion.

From my point of view this should be a quite common scenario in a CAL-application?

Thanks! =)