C#C
C#15mo ago
Vir Godem

WPF Submenu Styling

I can't seem to figure how to get rid of the border in submenus in WPF. More specifically, can't figure out how to get rid of that border.

For minimum repo, create a new WPF application and have this as your MainWindow's xml file::

<Window x:Class="SubmenustyleTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:SubmenustyleTest"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <StackPanel>
        <Menu>
            <MenuItem Header="File">
                <MenuItem.ItemContainerStyle>
                    <Style>
                        <Setter Property="ItemsControl.Background" Value="LightCoral"/>
                        <Setter Property="ItemsControl.BorderBrush" Value="OrangeRed"/>
                        <Setter Property="ItemsControl.Margin" Value="0"/>
                    </Style>
                </MenuItem.ItemContainerStyle>
                
                <MenuItem Header="Open"/>
                <MenuItem Header="Save"/>
            </MenuItem>
        </Menu>
    </StackPanel>
</Window>
Screenshot_134.png
Was this page helpful?