Reputation: 59346
I've troubles getting to play a <Menu/>
within a <Toolbar/>
to play nice. My Example, as follows is placed in an empty window in a default WpfApplication project template from VS2010:
<DockPanel>
<ToolBar DockPanel.Dock="Top">
<Button Content="Button 1"/>
<Button Content="Button 2"/>
<Separator/>
<CheckBox Content="CheckBox 1"/>
<CheckBox Content="CheckBox 2"/>
<Separator/>
<Menu>
<MenuItem Header="Menu">
<MenuItem Header="File">
<MenuItem Header="Copy"/>
<MenuItem Header="Paste"/>
</MenuItem>
</MenuItem>
</Menu>
</ToolBar>
<Menu DockPanel.Dock="Top">
<MenuItem Header="Menu">
<MenuItem Header="File">
<MenuItem Header="Copy"/>
<MenuItem Header="Paste"/>
</MenuItem>
</MenuItem>
</Menu>
<Grid>
</Grid>
</DockPanel>
The default style mis-aligns both the label and the hover-indicator:
I'm no designer, nor a WPF-guru, so my simple attempts at getting the menu's style closer to the buttons have failed catastrophically.
Has anybody a simple (ideally based on Toolbar.MenuStyleKey
) Style to get the Menu back in line?
Upvotes: 3
Views: 874
Reputation: 15823
Here is a quick thing that seemed to work in KaXaml:
<ToolBar DockPanel.Dock="Top">
<Button Content="Button 1"/>
<Button Content="Button 2"/>
<Separator/>
<CheckBox Content="CheckBox 1"/>
<CheckBox Content="CheckBox 2"/>
<Separator/>
<Menu Margin="0, -1, 0, 0" Style="{x:Null}">
<MenuItem Header="Menu">
<MenuItem Header="File">
<MenuItem Header="Copy"/>
<MenuItem Header="Paste"/>
</MenuItem>
</MenuItem>
</Menu>
</ToolBar>
Upvotes: 1