How to Create a menu with displaying SubMenu Items in two columns WPF C#

149 Views Asked by At

I created a menu bar showing the submenu in two columns, but it is displaying a hover/highlight effect for the whole panel. I want to remove that hover effect from the panel.

<MenuItem  Header="Top Menu">
            <StackPanel Orientation="Horizontal">
                <StackPanel >
                    <MenuItem Header="Sub1"></MenuItem>
                    <MenuItem Header="Sub2"></MenuItem>
                </StackPanel>
                <StackPanel >
                    <MenuItem Header="Sub3"></MenuItem>
                    <MenuItem Header="Sub4"></MenuItem>
                </StackPanel>
            </StackPanel>
        </MenuItem>

View menu bar

1

There are 1 best solutions below

0
On

Unfortunately the hover color of the menu item lives in the ControlTemplate triggers, which take precedence over style triggers. As a result, you cannot override the hover color with a style.

Instead, you will need to provide a new ControlTemplate for the MenuItem with a hover color you desire.

See more here: https://stackoverflow.com/a/34889755/14438772