How to add Submenus in a Menu
24,358
Solution 1
For submenus you can add as many MenuItem nested inside.
<Menu>
<MenuItem Header="File">
<MenuItem Header="Open"/>
<MenuItem Header="Close"/>
</MenuItem>
<MenuItem Header="Edit">
<MenuItem Header="Copy"/>
<MenuItem Header="Paste"/>
</MenuItem>
<MenuItem Header="Options"/>
Solution 2
Just redefine the ItemsPanel
:
<Menu>
<Menu.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</Menu.ItemsPanel>
<MenuItem Header="Foo"/>
<MenuItem Header="Bar"/>
<MenuItem Header="Baz"/>
...
</Menu>
Note that this will not get rid of the vertical gradient effect in Vista/Win7 menus. If you want that, set Menu.Background
property to whatever you want (could even be Transparent
).
Author by
Admin
Updated on November 07, 2021Comments
-
Admin over 2 years
How does one make submenu's in WPF and are their ways to orientate the layout?