Hi. I am working on some XAML for a wpf application and I am having some trouble getting it to do what I want. Here is a sample of my XAML:
<!-- Tool Bar Tray -->
<ToolBarTray Name="toolBarTray1" DockPanel.Dock="Top">
<!-- File And Edit Tools -->
<ToolBar Name="toolBar1" Band="1" BandIndex="1">
<!-- Regular Items -->
<Button>A</Button>
<Button>B</Button>
<!-- Overflow Menu For Special Items -->
<MenuItem ToolBar.OverflowMode="Always" Header="Special Items">
<MenuItem Header="C"/>
<MenuItem Header="D"/>
</MenuItem>
</ToolBar>
</ToolBarTray>
When I click on the overflow button of my toolbar, the "Special Items" MenuItem appears with a little arrow next to it, indicating nested elements. However, when I hover the mouse over "Special Items" or try to click on it, the MenuItems "C" and "D" are not being displayed.
I was hoping that MenuItem would just work outside of a Menu, but I tried to do the straight-forward thing, just in case. Including these MenuItems inside a Menu and, instead, giving this Menu the ToolBar.OverflowMode="Always" property produces some unwanted styling. The arrow is no longer present, the "Special Items" entry needs to be clicked on to activate the sub-menu and the sub-menu positioning looks a little off.
Does anyone know what is going on?
Edit: Adding a menu to the overflow is producing exactly what I requested (big surprise). What I am after is a way to convert top-level headers and items to the sub-menu level. I have turned towards this control template example on MSDN for a solution (below).
Edit,Edit: @gcores (comment discussion): Really? Am I missing something?
<ToolBar Name="toolBar1" Band="1" BandIndex="4">
<!-- Displayed Buttons -->
<Button>A</Button>
<Button>B</Button>
<!-- Special Items Menu -->
<Menu ToolBar.OverflowMode="Always" >
<MenuItem Style="{StaticResource MenuItemStyle}" Header="Special">
<MenuItem Header="C"/>
<MenuItem Header="D"/>
</MenuItem>
</Menu>
</ToolBar>
This snippet doesn't work for me. I have to click on 'Special' for the sub-menu to display.