Place a dividing line in a menu in WPF

Andrew Shepherd picture Andrew Shepherd · Aug 18, 2009 · Viewed 28.8k times · Source

In XAML, how do I put a standard dividing line in a menu?

eg

<MenuItem Header="_File" Name="m_fileMenu">
    <MenuItem Header="_Open" Command="ApplicationCommands.Open"/>
    <!-- Trying to put a divider here! -->
    <MenuItem Header="-" />  <!-- Wrong guess -->
    <MenuItem Header="E_xit" Command="ApplicationCommands.Close" />
</MenuItem>

Answer

RichieHindle picture RichieHindle · Aug 18, 2009

Use a Separator like this:

<MenuItem Header="_Open" Command="ApplicationCommands.Open" />
<Separator />
<MenuItem Header="E_xit" Command="ApplicationCommands.Close" />