title: RibbonApplicationMenu: getting rid of the AuxiliaryPane
body: <p>It so happened that the application I'm working on doesn't operate on documents, so there's no need in displaying the recently opened documents list in the application menu.<br>
  But - annoyingly - there are no properties readily available in the <code>RibbonApplicationMenu</code> class to hide the unused <code>AuxiliaryPane</code> (for which, curiously, the property does exist, but is marked as "internal").<br>
  Of course, I can just leave it there - but that's... untidy.</p>
  
  <p>So, here's the solution I came up with.<br>
  Hope it will be helpful for anyone else :-)  </p>
  
  <p>The general idea is to subclass the <code>RibbonApplicationMenu</code>, find the template child corresponding to the menu's Popup, and overrule its <code>Width</code> (after a number of frustrating experiments it became evident that doing that neither for <code>PART_AuxiliaryPaneContentPresenter</code> nor for <code>PART_FooterPaneContentPresenter</code> - nor for the both - could achieve anything).</p>
  
  <p>Well, without further ado, here's the code:</p>
  
  <pre><code>public class SlimRibbonApplicationMenu : RibbonApplicationMenu
  {
      private const double DefaultPopupWidth = 180;
  
      public double PopupWidth
      {
          get { return (double)GetValue(PopupWidthProperty); }
          set { SetValue(PopupWidthProperty, value); }
      }
  
      public static readonly DependencyProperty PopupWidthProperty =
          DependencyProperty.Register("PopupWidth", typeof(double), 
          typeof(SlimRibbonApplicationMenu), new UIPropertyMetadata(DefaultPopupWidth));
  
  
      public override void OnApplyTemplate()
      {
          base.OnApplyTemplate();
          this.DropDownOpened += 
              new System.EventHandler(SlimRibbonApplicationMenu_DropDownOpened);
      }
  
      void SlimRibbonApplicationMenu_DropDownOpened(object sender, System.EventArgs e)
      {
          DependencyObject popupObj = base.GetTemplateChild("PART_Popup");
          Popup popupPanel = (Popup)popupObj;
          popupPanel.Width = (double)GetValue(PopupWidthProperty);
      }
  }
  </code></pre>
  
  <p>As a side note, I tried to find any way to resolve the desired width based on the max width of the ApplicationMenu's Items (rather than setting it explicitly through the DependencyProperty in XAML) - but to no avail.<br>
  Given my despise to "magic numbers", any suggestion on <em>that</em> will be deeply appreciated.</p>