title: WPF Custom "Toolbox" Selector control
body: <p>I am trying to create a custom control, which behaves a bit like one of the "rows" in the toolbox in Expression Blend.</p>
  
  <p>When closed, it displays the first of its items, and when the user holds the mouse down over it for a second or so, it "expands" to reveal the other items in a popup <em>excluding the item which is currently selected</em> (the item which was clicked on still remains visible, but is not grouped with the others).</p>
  
  <p>I have managed to make a control which inherits from <code>ContentControl</code> displays one item and then reveals the others when expanded, but the item which is displayed first does not change when one is clicked.</p>
  
  <p>The template is as follows:</p>
  
  <pre><code>&lt;Border Background="{TemplateBinding Background}"
  BorderBrush="{TemplateBinding BorderBrush}"
  BorderThickness="{TemplateBinding BorderThickness}"&gt;
  &lt;Grid&gt;
      &lt;ContentPresenter Content="{TemplateBinding MainItem}" /&gt; // The item that is seen even when not expanded
      &lt;Popup Name="Popup" Placement="Right" IsOpen="{TemplateBinding IsExpanded}" AllowsTransparency="True" Focusable="False" PopupAnimation="Fade"&gt;
          &lt;Border Name="SubmenuBorder" SnapsToDevicePixels="True" BorderThickness="0" &gt;
              &lt;StackPanel Orientation="Horizontal" IsItemsHost="True" /&gt; // The items only seen when expanded
          &lt;/Border&gt;
      &lt;/Popup&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>At the moment, I have to manually set the <code>MainItem</code> in XAML and it is not a member of the <code>Items</code> property of the <code>ContentControl</code>.</p>
  
  <p>Is there a way to achieve this functionality where all items are part of the <code>Items</code> collection and are automatically not shown when an <code>IsSelected</code> property or something is set, and are then shown where the current <code>MainItem</code> is shown when this is the case?</p>
  
  <p>I tried changing it to a <code>Selector</code> and using a filter on the <code>Items</code> to achieve this and binding the first <code>ContentPresenter</code> to the <code>SelectedItem</code> but it didn't seem to work.</p>
  
  <p>If possible, the order of the items only visible when the control is expanded should be the same as the order in which they are laid out in XAML, with the currently selected item missing.</p>
  
  <p>Thanks</p>