Hi all,

This is my first post here, since I am just starting out WPF.
I wanted to create my own custom style menu but I ran into a few problems.

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 

        <Style x:Key="InformMenu" TargetType="{x:Type MenuItem}">
            <Setter Property="Foreground" Value="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Menu}}}"/>
            <Setter Property="Template">
                    <ControlTemplate TargetType="{x:Type MenuItem}">
                        <!--Apply the background and set the BorderColor, Thickness and Radius -->
                        <Border x:Name="Border" Background="LightGray" BorderBrush="Black" BorderThickness="1" CornerRadius="3">
                                <ColumnDefinition x:Name="Col0" MinWidth="17" Width="Auto" SharedSizeGroup="MenuItemIconColumnGroup"/>
                                <ColumnDefinition Width="Auto" SharedSizeGroup="MenuTextColumnGroup"/>
                                <ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIGTColumnGroup"/>
                                <ColumnDefinition x:Name="Col3" Width="14"/>

                                <!-- Content for the menu text etc -->
                                <ContentPresenter Grid.Column="1"
                                          Margin="{TemplateBinding Padding}"

                                <!-- The Popup is the body of the menu which expands down or across depending on the level of the item -->
                                <Popup IsOpen="{Binding Path=IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}" Placement="Top" x:Name="SubMenuPopup" Focusable="false" PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}">
                                    <Border x:Name="SubMenuBorder" Background="Transparent" CornerRadius="0" BorderBrush="Transparent" BorderThickness="0" Padding="0,0,0,0">
                                        <Grid x:Name="SubMenu" Grid.IsSharedSizeScope="true">
                                            <!-- StackPanel holds children of the menu. This is set by IsItemsHost=True -->
                                            <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle"/>

                        <!-- These triggers re-configure the four arrangements of MenuItem to show different levels of menu via Role -->
                            <!-- Role = TopLevelHeader : this is the root menu item in a menu; the Popup expands down -->
                            <!-- TopLevel Menu Item with PopUp -->
                            <Trigger Property="Role" Value="TopLevelHeader">
                                <Setter Property="Padding" Value="5,0,5,0"/>
                                <!-- Set the placement value to orient popup direction -->
                                <Setter Property="Placement" Value="Bottom" TargetName="SubMenuPopup"/>
                                <Setter Property="MinWidth" Value="0" TargetName="Col0"/>
                                <Setter Property="Width" Value="40" TargetName="Col3"/>

                            <!-- Role = TopLevelItem :  this is a child menu item from the top level without any child items-->
                            <!-- TopLevel Menu Item with no PopUp (empty) -->
                            <Trigger Property="Role" Value="TopLevelItem">
                                <Setter Property="Padding" Value="5,0,5,0"/>

                            <!-- Role = SubMenuHeader : this is a child menu item which does not have children -->
                            <Trigger Property="Role" Value="SubmenuHeader">
                                <Setter Property="DockPanel.Dock" Value="Top"/>
                                <Setter Property="Padding" Value="0,2,0,2"/>

                            <!-- Role = SubMenuItem : this is a child menu item which has children-->
                            <Trigger Property="Role" Value="SubmenuItem">
                                <Setter Property="DockPanel.Dock" Value="TOP"/>
                                <Setter Property="Padding" Value="0,2,0,2"/>

                            <!-- Using the system colors for the Menu Highlight and IsEnabled-->
                            <Trigger Property="IsHighlighted" Value="true">
                                <!-- Set the MenuItem background Color when Mouse Hoover -->
                                <Setter Property="Background" Value="Darkgray" TargetName="Border"/>
                                <!-- Set the MenuItem text Color when Mouse Hoover -->
                                <Setter Property="Foreground" Value="White"/>


    <StackPanel HorizontalAlignment="Center">

            <MenuItem Style="{StaticResource InformMenu}" Header="_File" >
                <MenuItem Style="{StaticResource InformMenu}" Header="_New..." />
                <MenuItem Style="{StaticResource InformMenu}" Header="_Open..." />
                <MenuItem Style="{StaticResource InformMenu}" Header="_Save" />
                <MenuItem Style="{StaticResource InformMenu}" Header="_Save As..." />
                <MenuItem Style="{StaticResource InformMenu}" Header="_Exit" />

When I take a look at this in the XAMP editor (VS) I see nice rounded menu items.

Name:  OK.jpg
Views: 36920
Size:  14.2 KB

But when I run the program I get a black square behind them, as shown in the next picture.

Name:  NOK.jpg
Views: 37097
Size:  6.1 KB

Any ideas on how to fix this?

I also noticed there is a slight shift between, in my example the File item and the popup. Can I get rid of this?
Is there also a way to have the submenu items borders overlap? So I get a one pixel separation instead of the two rounded borders now touching eachother and thus giving me 2 pixels?

Hope I made myself clear, since English is not my native language,