RibbonRegion tu support navigating to a list of views per module

Topics: Prism v4 - WPF 4
May 29, 2012 at 9:08 PM

Hello,

I want to create an application using Prism V4 WPF which has a ribbon control on the shell with shell dedicated tabs and a region (created a region adapter for ribbon control) dedicated to modules. My application can have only one active module at a time and each module can have more than one view(ribbon tabs) to place into ribbon region. Now I am using navigation to navigate to the specific view when a module becomes active. My ribbon viewmodel implements IRegionMemberLifetime interface and sets KeepAlive property to false to remove view from region when module becomes inactive. The problem is, I don't know how to navigate to multiple views(ribbon tabs) and keep the previously navigated ribbon view alive for the same module and when the module becomes inactive to set all KeepAlive to false. Also, the solution might be another implementation of my adapter but I can't see it...

 

Regards,

Bogdan

Developer
May 30, 2012 at 9:18 PM

Hi Bogdan,

Take into account that the Prism Library provides the following region adapters out of the box that can be used as a starting point to create your custom region adapter that suits your needs:

  • ContentControlRegionAdapter. This adapter adapts controls of type System.Windows.Controls.ContentControl and derived classes
  • SelectorRegionAdapter. This adapter adapts controls derived from the class System.Windows.Controls.Primitives.Selector, such as the System.Windows.Controls.TabControl control.
  • ItemsControlRegionAdapter. This adapter adapts controls of type System.Windows.Controls.ItemsControl and derived classes

You could find more information about this in the following chapter of the Prism documentation:

Particularly, note that if your region adapter's CreateRegion method returns an AllActiveRegion, this region will keep all the views in it as active and the deactivation of these views will not be allowed, hence if this is your case the RegionMemberLifetimeBehavior may not work properly. Instead you could return a Region, which is usually used for controls derived from the Selector class.

Also, you could give additional functionality to the region by overriding the AttachBehaviors method in your region adapter. For example you could check the SelectorItemsSourceSyncBehavior used in the SelectorRegionAdapter provided with Prism, which is used for controls that derive from Selector, such as a tab control in WPF and is responsible for synchronizing the views in the region with the items of the selector, and then synchronizing the active views in the region with the selected items of the selector.

Additionally,if you believe that ribbon region adapters should be supported by Prism out of the box, you can vote in the following work item so that the Prism team analyzes it for a future release:

Regards,

Agustin Adami
http://blogs.southworks.net/aadami

May 31, 2012 at 10:37 AM

Thank you for your answer. I've implemented a custom behavior wich does what I want.