title: Inject / Navigate RibbonTabItems depending on selected / loaded module
body: <p>I have got following problem:</p>
  
  <p>There is a Ribbon-region in the Shell, let´s call it the "ShellRibbonRegion". There is also a task button region "ShellTaskButtonRegion" (<a href="http://www.codeproject.com/Articles/165370/Creating-View-Switching-Applications-with-Prism-4" rel="nofollow">similar to Creating View-Switching Applications with Prism 4</a>).</p>
  
  <p>There are e.g. three modules. Each module has a different number of RibbonTabItems. Module 1 has one RibbonTabItem, module 2 four and module 3 one.</p>
  
  <p>The goal is now to add the RibbonTabItems to the "ShellRibbonRegion" after the "TaskButton" of a module is clicked. I already have written a custom RegionAdapter, but the problem is either only one RibbonTabItem (SingleActiveRegion) is shown or all (AllActiveRegion) RibbonTabItems from all modules.</p>
  
  <pre><code>public class RibbonRegionAdapter : RegionAdapterBase&lt;Ribbon&gt;
  {
      /// &lt;summary&gt;
      /// Default constructor.
      /// &lt;/summary&gt;
      /// &lt;param name="behaviorFactory"&gt;Allows the registration of the default set of RegionBehaviors.&lt;/param&gt;
      public RibbonRegionAdapter(IRegionBehaviorFactory behaviorFactory)
          : base(behaviorFactory)
      {
      }
  
      /// &lt;summary&gt;
      /// Adapts a WPF control to serve as a Prism IRegion. 
      /// &lt;/summary&gt;
      /// &lt;param name="region"&gt;The new region being used.&lt;/param&gt;
      /// &lt;param name="regionTarget"&gt;The WPF control to adapt.&lt;/param&gt;
      protected override void Adapt(IRegion region, Ribbon regionTarget)
      {
          regionTarget.SelectedTabChanged += (sender, args) =&gt;
          {
              if (regionTarget.SelectedTabItem == null)
                  return;
  
              //region.Activate(regionTarget.SelectedTabItem);
          };
  
          region.Views.CollectionChanged += (sender, e) =&gt;
          {
              switch (e.Action)
              {
                  case NotifyCollectionChangedAction.Add:
                      foreach (UIElement element in e.NewItems)
                      {
                          if(element is Ribbon)
                              this.AddRibbon(element as Ribbon, regionTarget, region);
                          else if(element is RibbonTabItem)
                              this.AddRibbonTabItem(element as RibbonTabItem, regionTarget, region);
                          else if(element is Backstage)
                              this.AddBackstage(element as Backstage, regionTarget);
                      }
                      break;
  
                  case NotifyCollectionChangedAction.Remove:
                      foreach (UIElement elementLoopVariable in e.OldItems)
                      {
                          var element = elementLoopVariable;
  
                          if (element is Ribbon)
                              this.RemoveRibbon(element as Ribbon, regionTarget);
                          else if (element is RibbonTabItem)
                              this.RemoveRibbonTabItem(element as RibbonTabItem, regionTarget);
                          else if (element is Backstage)
                              this.RemoveBackstage(element as Backstage, regionTarget);
                      }
                      break;
              }
          };
      }
  
      #region Add
      private void AddRibbon(Ribbon ribbon, Ribbon targetRibbon, IRegion region)
      {
          //Add tabs
          foreach (var ribbonTabItem in ribbon.Tabs)
          {
              this.AddRibbonTabItem(ribbonTabItem, targetRibbon, region);
          }
      }
  
      private void AddRibbonTabItem(RibbonTabItem ribbonTabItem, Ribbon targetRibbon, IRegion region)
      {
          if (!targetRibbon.Tabs.Contains(ribbonTabItem))
              targetRibbon.Tabs.Add(ribbonTabItem);
      }
  
      private void AddBackstage(Backstage backstage, Ribbon targetRibbon)
      {
  
      }
      #endregion
  
      #region Remove
      private void RemoveRibbon(Ribbon ribbon, Ribbon targetRibbon)
      {
          var tmp = new List&lt;RibbonTabItem&gt;(ribbon.Tabs);
          //Add tabs
          foreach (var ribbonTabItem in tmp)
          {
              if (targetRibbon.Tabs.Contains(ribbonTabItem)) this.RemoveRibbonTabItem(ribbonTabItem, targetRibbon);
          }
      }
  
      private void RemoveRibbonTabItem(RibbonTabItem ribbonTabItem, Ribbon targetRibbon)
      {
          if (ribbonTabItem is IRegionMemberLifetime)
          {
              var rml = (IRegionMemberLifetime)ribbonTabItem;
              if (!rml.KeepAlive) targetRibbon.Tabs.Remove(ribbonTabItem);
              return;
          }
          targetRibbon.Tabs.Remove(ribbonTabItem);
      }
  
      private void RemoveBackstage(Backstage backstage, Ribbon targetRibbon)
      {
  
      }
      #endregion
  
      protected override IRegion CreateRegion()
      {
          return new AllActiveRegion();
      }
  }
  </code></pre>
  
  <p>The desired behaviour is following:</p>
  
  <p>The "TaskButton" of a module is clicked: All RibbonTabItems which don´t belong to this module are removed from the region and the tab items from "clicked" module are added. </p>
  
  <p>How can I achieve this behaviour?</p>