Menu item WPF custom template

Hi, I create a custom menu with menu items. I manage change the background of the menu item but still it is surrounded of some grey container. I don't find in the template for menu item nothing that can customaze this container.
Do you have any suggestions?
Screen-Shot-03-06-18-at-01.55-PM.PNG
LVL 1
mastiSoftAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Juan OcasioApplication DeveloperCommented:
Did you check the XAML for any margins or padding?
0
mastiSoftAuthor Commented:
Yes I did but there is only infromation for Icon, text and stuff like that.
0
Juan OcasioApplication DeveloperCommented:
0
mastiSoftAuthor Commented:
Thank you but it this is not resolved the problem I have.
0
MishaProgrammerCommented:
If you want to hide "container" of menu, you should use "Popup"

Try this:

<Window x:Class="TestMenu.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">

    <Window.Resources>
        <ControlTemplate x:Key="{x:Static MenuItem.TopLevelHeaderTemplateKey}" TargetType="{x:Type MenuItem}">
            <Border Name="Border" >
                <Grid>
                    <ContentPresenter Margin="6,3,6,3" ContentSource="Header" RecognizesAccessKey="True" />
                    <Popup Name="Popup" Placement="Bottom" IsOpen="{TemplateBinding IsSubmenuOpen}" AllowsTransparency="True" Focusable="False" PopupAnimation="Fade">
                        <Border Name="SubmenuBorder" SnapsToDevicePixels="True" Background="Transparent">
                            <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" />
                        </Border>
                    </Popup>
                </Grid>
            </Border>
        </ControlTemplate>
    </Window.Resources>
    
    <Grid>
        <Menu Height="25" VerticalAlignment="Top">
            <MenuItem Header="File"  >
                <MenuItem Header="New" Background="Red" ></MenuItem>
                <MenuItem Header="Open" ></MenuItem>
                <MenuItem Header="Save" ></MenuItem>
            </MenuItem>
        </Menu>
    </Grid>
</Window>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WPF

From novice to tech pro — start learning today.