<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:ModernWpf.Controls"
    xmlns:primitives="clr-namespace:ModernWpf.Controls.Primitives"
    xmlns:sys="clr-namespace:System;assembly=mscorlib">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="TextStyles.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <sys:Double x:Key="MenuBarHeight">40</sys:Double>
    <Thickness x:Key="MenuBarItemButtonPadding">10,4,10,4</Thickness>
    <Thickness x:Key="MenuBarItemMargin">4,4,4,4</Thickness>
    <Thickness x:Key="MenuFlyoutScrollerMargin">0,4,0,4</Thickness>
    <Thickness x:Key="MenuFlyoutItemRevealBorderThickness">1</Thickness>
    <Thickness x:Key="ToggleMenuFlyoutItemRevealBorderThickness">1</Thickness>
    <Thickness x:Key="MenuFlyoutSubItemRevealBorderThickness">1</Thickness>

    <primitives:SharedSizeGroupConverter x:Key="SharedSizeGroupConverter" />

    <Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=MenuScrollViewer}" TargetType="ScrollViewer">
        <Setter Property="HorizontalScrollBarVisibility" Value="Disabled" />
        <Setter Property="VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="PanningMode" Value="VerticalOnly" />
    </Style>

    <Style x:Key="DefaultMenuItemSeparatorStyle" TargetType="Separator">
        <Setter Property="Background" Value="{DynamicResource MenuFlyoutSeparatorBackground}" />
        <Setter Property="Padding" Value="{DynamicResource MenuFlyoutSeparatorThemePadding}" />
        <Setter Property="SnapsToDevicePixels" Value="true" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Separator">
                    <Rectangle
                        Fill="{TemplateBinding Background}"
                        Margin="{TemplateBinding Padding}"
                        Height="{DynamicResource MenuFlyoutSeparatorThemeHeight}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="Separator" BasedOn="{StaticResource DefaultMenuItemSeparatorStyle}" />

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=TopLevelItemTemplateKey}" TargetType="MenuItem">
        <local:BorderEx x:Name="ContentRoot"
                        Background="{TemplateBinding Background}"
                        CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}"
                        ClipToBounds="True"
                        SnapsToDevicePixels="True">
            <Grid>
                <Border
                    x:Name="Background"
                    Background="{TemplateBinding Background}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    BorderBrush="{TemplateBinding BorderBrush}" />

                <ContentPresenter
                    ContentSource="Header"
                    RecognizesAccessKey="True"
                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                    Margin="{StaticResource MenuBarItemButtonPadding}"
                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
            </Grid>
        </local:BorderEx>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter TargetName="Background" Property="Background" Value="{DynamicResource MenuBarItemBackgroundPointerOver}" />
                <Setter TargetName="Background" Property="BorderBrush" Value="{DynamicResource MenuBarItemBorderBrushPointerOver}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter TargetName="Background" Property="Background" Value="{DynamicResource MenuBarItemBackgroundPressed}" />
                <Setter TargetName="Background" Property="BorderBrush" Value="{DynamicResource MenuBarItemBorderBrushPressed}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=TopLevelHeaderTemplateKey}" TargetType="MenuItem">
        <local:BorderEx x:Name="ContentRoot"
                        Background="{TemplateBinding Background}"
                        CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}"
                        ClipToBounds="True"
                        SnapsToDevicePixels="True">
            <Grid>
                <Border
                    x:Name="Background"
                    Background="{TemplateBinding Background}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    BorderBrush="{TemplateBinding BorderBrush}" />

                <ContentPresenter
                    ContentSource="Header"
                    RecognizesAccessKey="True"
                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                    Margin="{StaticResource MenuBarItemButtonPadding}"
                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />

                <primitives:MenuPopup
                    x:Name="PART_Popup"
                    AllowsTransparency="true"
                    Focusable="false"
                    IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}"
                    PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}"
                    Placement="Bottom">
                    <primitives:ThemeShadowChrome
                        IsShadowEnabled="{DynamicResource {x:Static SystemParameters.DropShadowKey}}"
                        CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}">
                        <Border
                            x:Name="SubMenuRoot"
                            Background="{DynamicResource MenuFlyoutPresenterBackground}"
                            CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}">
                            <Grid>
                                <ScrollViewer
                                    x:Name="SubMenuScrollViewer"
                                    Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer,
                                    TypeInTargetAssembly={x:Type FrameworkElement}}}"
                                    Margin="{DynamicResource MenuFlyoutPresenterThemePadding}"
                                    MinWidth="{DynamicResource FlyoutThemeMinWidth}">
                                    <ItemsPresenter
                                        RenderOptions.ClearTypeHint="Enabled"
                                        KeyboardNavigation.DirectionalNavigation="Cycle"
                                        KeyboardNavigation.TabNavigation="Cycle"
                                        Grid.IsSharedSizeScope="true"
                                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                </ScrollViewer>
                                <Border
                                    x:Name="SubMenuBorder"
                                    BorderBrush="{DynamicResource MenuFlyoutPresenterBorderBrush}"
                                    BorderThickness="{DynamicResource MenuFlyoutPresenterBorderThemeThickness}"
                                    CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}" />
                            </Grid>
                        </Border>
                    </primitives:ThemeShadowChrome>
                </primitives:MenuPopup>
            </Grid>
        </local:BorderEx>
        <ControlTemplate.Triggers>
            <Trigger Property="IsSuspendingPopupAnimation" Value="true">
                <Setter TargetName="PART_Popup" Property="PopupAnimation" Value="None" />
            </Trigger>
            <Trigger SourceName="PART_Popup" Property="IsSuspendingAnimation" Value="true">
                <Setter TargetName="PART_Popup" Property="PopupAnimation" Value="None" />
            </Trigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter TargetName="Background" Property="Background" Value="{DynamicResource MenuBarItemBackgroundPointerOver}" />
                <Setter TargetName="Background" Property="BorderBrush" Value="{DynamicResource MenuBarItemBorderBrushPointerOver}" />
            </Trigger>
            <!-- Selected -->
            <Trigger Property="IsSubmenuOpen" Value="True">
                <Setter TargetName="Background" Property="Background" Value="{DynamicResource MenuBarItemBackgroundSelected}" />
                <Setter TargetName="Background" Property="BorderBrush" Value="{DynamicResource MenuBarItemBorderBrushSelected}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter TargetName="Background" Property="Background" Value="{DynamicResource MenuBarItemBackgroundPressed}" />
                <Setter TargetName="Background" Property="BorderBrush" Value="{DynamicResource MenuBarItemBorderBrushPressed}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- DefaultMenuFlyoutSubItemStyle -->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=SubmenuItemTemplateKey}" TargetType="MenuItem">
        <ControlTemplate.Resources>
            <StreamGeometry x:Key="CheckMark">F1 M 17.939453 5.439453 L 7.5 15.888672 L 2.060547 10.439453 L 2.939453 9.560547 L 7.5 14.111328 L 17.060547 4.560547 Z</StreamGeometry>
        </ControlTemplate.Resources>
        <Border
            x:Name="LayoutRoot"
            SnapsToDevicePixels="true"
            Padding="{TemplateBinding Padding}"
            Background="{TemplateBinding Background}"
            BorderBrush="{TemplateBinding BorderBrush}"
            BorderThickness="{TemplateBinding BorderThickness}"
            Margin="{DynamicResource MenuFlyoutItemMargin}"
            CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition SharedSizeGroup="{TemplateBinding Visibility, Converter={StaticResource SharedSizeGroupConverter}, ConverterParameter=MenuItemCheckColumnGroup}" Width="Auto" />
                    <ColumnDefinition SharedSizeGroup="{TemplateBinding Visibility, Converter={StaticResource SharedSizeGroupConverter}, ConverterParameter=MenuItemIconColumnGroup}" Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <local:FontIconFallback
                    x:Name="CheckGlyph"
                    FontFamily="{DynamicResource SymbolThemeFontFamily}"
                    Data="{StaticResource CheckMark}"
                    FontSize="12"
                    Foreground="{DynamicResource ToggleMenuFlyoutItemCheckGlyphForeground}"
                    Opacity="0"
                    Margin="0,0,16,0"
                    Visibility="Collapsed" />
                <Viewbox
                    x:Name="IconRoot"
                    Grid.Column="1"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Center"
                    Width="16"
                    Height="16"
                    Margin="0,0,12,0">
                    <ContentPresenter
                        x:Name="IconContent"
                        ContentSource="Icon"
                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                </Viewbox>
                <ContentPresenter
                    x:Name="ContentPresenter"
                    Grid.Column="2"
                    ContentSource="Header"
                    RecognizesAccessKey="True"
                    TextElement.Foreground="{TemplateBinding Foreground}"
                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                <TextBlock
                    x:Name="KeyboardAcceleratorTextBlock"
                    Grid.Column="3"
                    Style="{StaticResource CaptionTextBlockStyle}"
                    Text="{TemplateBinding InputGestureText}"
                    Margin="24,0,0,0"
                    Foreground="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForeground}"
                    HorizontalAlignment="Right"
                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter Property="Visibility" TargetName="IconRoot" Value="Collapsed" />
            </Trigger>
            <Trigger Property="InputGestureText" Value="">
                <Setter Property="Visibility" TargetName="KeyboardAcceleratorTextBlock" Value="Collapsed" />
            </Trigger>
            <Trigger Property="IsChecked" Value="True">
                <Setter TargetName="CheckGlyph" Property="Opacity" Value="1" />
            </Trigger>
            <Trigger Property="IsCheckable" Value="True">
                <Setter TargetName="CheckGlyph" Property="Visibility" Value="Visible" />
            </Trigger>
            <Trigger Property="IsHighlighted" Value="True">
                <Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource MenuFlyoutItemBackgroundPointerOver}" />
                <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutItemForegroundPointerOver}" />
                <Setter TargetName="CheckGlyph" Property="Foreground" Value="{DynamicResource MenuFlyoutItemForegroundPointerOver}" />
                <Setter TargetName="IconContent" Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutItemForegroundPointerOver}" />
                <Setter TargetName="KeyboardAcceleratorTextBlock" Property="Foreground" Value="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForegroundPointerOver}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource MenuFlyoutItemBackgroundPressed}" />
                <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutItemForegroundPressed}" />
                <Setter TargetName="CheckGlyph" Property="Foreground" Value="{DynamicResource MenuFlyoutItemForegroundPressed}" />
                <Setter TargetName="IconContent" Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutItemForegroundPressed}" />
                <Setter TargetName="KeyboardAcceleratorTextBlock" Property="Foreground" Value="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForegroundPressed}" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource MenuFlyoutItemBackgroundDisabled}" />
                <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutItemForegroundDisabled}" />
                <Setter TargetName="CheckGlyph" Property="Foreground" Value="{DynamicResource MenuFlyoutItemForegroundDisabled}" />
                <Setter TargetName="IconContent" Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutItemForegroundDisabled}" />
                <Setter TargetName="KeyboardAcceleratorTextBlock" Property="Foreground" Value="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForegroundDisabled}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- DefaultMenuFlyoutItemStyle -->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=SubmenuHeaderTemplateKey}" TargetType="MenuItem">
        <ControlTemplate.Resources>
            <StreamGeometry x:Key="ChevronRight">M 5.029297 19.091797 L 14.111328 10 L 5.029297 0.908203 L 5.908203 0.029297 L 15.888672 10 L 5.908203 19.970703 Z</StreamGeometry>
        </ControlTemplate.Resources>
        <Border
            x:Name="LayoutRoot"
            Padding="{TemplateBinding Padding}"
            Background="{TemplateBinding Background}"
            BorderBrush="{TemplateBinding BorderBrush}"
            BorderThickness="{TemplateBinding BorderThickness}"
            Margin="{DynamicResource MenuFlyoutItemMargin}"
            CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}"
            SnapsToDevicePixels="True">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition SharedSizeGroup="MenuItemCheckColumnGroup" Width="Auto" />
                    <ColumnDefinition SharedSizeGroup="MenuItemIconColumnGroup" Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <Viewbox
                    x:Name="IconRoot"
                    Grid.Column="1"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Center"
                    Width="16"
                    Height="16"
                    Margin="0,0,12,0">
                    <ContentPresenter x:Name="IconContent" ContentSource="Icon" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                </Viewbox>
                <ContentPresenter
                    x:Name="ContentPresenter"
                    Grid.Column="2"
                    ContentSource="Header"
                    RecognizesAccessKey="True"
                    TextElement.Foreground="{TemplateBinding Foreground}"
                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                <local:FontIconFallback
                    x:Name="SubItemChevron"
                    Grid.Column="3"
                    Data="{StaticResource ChevronRight}"
                    FontFamily="{DynamicResource SymbolThemeFontFamily}"
                    FontSize="12"
                    Foreground="{DynamicResource MenuFlyoutSubItemChevron}"
                    Margin="{DynamicResource MenuFlyoutItemChevronMargin}">
                    <UIElement.RenderTransform>
                        <TranslateTransform Y="1" />
                    </UIElement.RenderTransform>
                </local:FontIconFallback>
                <Popup
                    x:Name="PART_Popup"
                    AllowsTransparency="true"
                    Focusable="false"
                    IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}"
                    PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}"
                    Placement="Right"
                    PlacementTarget="{Binding ElementName=LayoutRoot}">
                    <Popup.PlacementRectangle>
                        <MultiBinding>
                            <MultiBinding.Converter>
                                <primitives:PlacementRectangleConverter Margin="4,-1" />
                            </MultiBinding.Converter>
                            <Binding ElementName="LayoutRoot" Path="ActualWidth" />
                            <Binding ElementName="LayoutRoot" Path="ActualHeight" />
                        </MultiBinding>
                    </Popup.PlacementRectangle>
                    <primitives:ThemeShadowChrome
                        IsShadowEnabled="{DynamicResource {x:Static SystemParameters.DropShadowKey}}"
                        CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}">
                        <Border
                            x:Name="SubMenuRoot"
                            Background="{DynamicResource MenuFlyoutPresenterBackground}"
                            CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}">
                            <Grid>
                                <ScrollViewer
                                    x:Name="SubMenuScrollViewer"
                                    Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer,
                                    TypeInTargetAssembly={x:Type FrameworkElement}}}"
                                    Margin="{DynamicResource MenuFlyoutPresenterThemePadding}"
                                    MinWidth="{DynamicResource FlyoutThemeMinWidth}">
                                    <ItemsPresenter
                                        RenderOptions.ClearTypeHint="Enabled"
                                        KeyboardNavigation.DirectionalNavigation="Cycle"
                                        KeyboardNavigation.TabNavigation="Cycle"
                                        Grid.IsSharedSizeScope="true"
                                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                </ScrollViewer>
                                <Border
                                    x:Name="SubMenuBorder"
                                    BorderBrush="{DynamicResource MenuFlyoutPresenterBorderBrush}"
                                    BorderThickness="{DynamicResource MenuFlyoutPresenterBorderThemeThickness}"
                                    CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}" />
                            </Grid>
                        </Border>
                    </primitives:ThemeShadowChrome>
                </Popup>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsSuspendingPopupAnimation" Value="true">
                <Setter TargetName="PART_Popup" Property="PopupAnimation" Value="None" />
            </Trigger>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter Property="Visibility" TargetName="IconRoot" Value="Collapsed" />
            </Trigger>
            <Trigger Property="IsHighlighted" Value="True">
                <Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource MenuFlyoutSubItemBackgroundPointerOver}" />
                <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutSubItemForegroundPointerOver}" />
                <Setter TargetName="SubItemChevron" Property="Foreground" Value="{DynamicResource MenuFlyoutSubItemChevronPointerOver}" />
                <Setter TargetName="IconContent" Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutSubItemForegroundPointerOver}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource MenuFlyoutSubItemBackgroundPressed}" />
                <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutSubItemForegroundPressed}" />
                <Setter TargetName="SubItemChevron" Property="Foreground" Value="{DynamicResource MenuFlyoutSubItemChevronPressed}" />
                <Setter TargetName="IconContent" Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutSubItemForegroundPointerOver}" />
            </Trigger>
            <Trigger Property="IsSubmenuOpen" Value="True">
                <Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource MenuFlyoutSubItemBackgroundSubMenuOpened}" />
                <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutSubItemForegroundSubMenuOpened}" />
                <Setter TargetName="SubItemChevron" Property="Foreground" Value="{DynamicResource MenuFlyoutSubItemChevronSubMenuOpened}" />
                <Setter TargetName="IconContent" Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutSubItemForegroundSubMenuOpened}" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource MenuFlyoutSubItemBackgroundDisabled}" />
                <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutSubItemForegroundDisabled}" />
                <Setter TargetName="SubItemChevron" Property="Foreground" Value="{DynamicResource MenuFlyoutSubItemChevronDisabled}" />
                <Setter TargetName="IconContent" Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutSubItemForegroundDisabled}" />
            </Trigger>
            <!--<Trigger SourceName="SubMenuScrollViewer" Property="ScrollViewer.CanContentScroll" Value="false" >
            <Setter TargetName="OpaqueRect" Property="Canvas.Top" Value="{Binding ElementName=SubMenuScrollViewer, Path=VerticalOffset}" />
            <Setter TargetName="OpaqueRect" Property="Canvas.Left" Value="{Binding ElementName=SubMenuScrollViewer, Path=HorizontalOffset}" />
            </Trigger>-->
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="DefaultMenuItemStyle" TargetType="MenuItem">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Background" Value="{DynamicResource MenuFlyoutItemBackground}" />
        <Setter Property="BorderBrush" Value="{DynamicResource MenuFlyoutItemBackgroundBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource MenuFlyoutItemBorderThickness}"/>
        <Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemForeground}" />
        <Setter Property="Padding" Value="{DynamicResource MenuFlyoutItemThemePaddingNarrow}" />
        <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="ScrollViewer.PanningMode" Value="Both" />
        <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
        <Setter Property="FocusVisualStyle" Value="{DynamicResource {x:Static SystemParameters.FocusVisualStyleKey}}" />
        <Setter Property="primitives:FocusVisualHelper.UseSystemFocusVisuals" Value="{DynamicResource UseSystemFocusVisuals}" />
        <Setter Property="primitives:ControlHelper.CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
        <Setter Property="Template" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=SubmenuItemTemplateKey}}" />
        <Style.Triggers>
            <Trigger Property="Role" Value="TopLevelHeader">
                <Setter Property="Background" Value="{DynamicResource MenuBarItemBackground}" />
                <Setter Property="BorderBrush" Value="{DynamicResource MenuBarItemBorderBrush}" />
                <Setter Property="BorderThickness" Value="{DynamicResource MenuBarItemBorderThickness}" />
                <Setter Property="Margin" Value="{DynamicResource MenuBarItemMargin}"/>
                <Setter Property="primitives:ControlHelper.CornerRadius" Value="{DynamicResource ControlCornerRadius}"/>
                <Setter Property="Template" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=TopLevelHeaderTemplateKey}}" />
                <Setter Property="IsTabStop" Value="True" />
            </Trigger>
            <Trigger Property="Role" Value="TopLevelItem">
                <Setter Property="Background" Value="{DynamicResource MenuBarItemBackground}" />
                <Setter Property="BorderBrush" Value="{DynamicResource MenuBarItemBorderBrush}" />
                <Setter Property="BorderThickness" Value="{DynamicResource MenuBarItemBorderThickness}" />
                <Setter Property="Margin" Value="{DynamicResource MenuBarItemMargin}"/>
                <Setter Property="primitives:ControlHelper.CornerRadius" Value="{DynamicResource ControlCornerRadius}"/>
                <Setter Property="Template" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=TopLevelItemTemplateKey}}" />
                <Setter Property="IsTabStop" Value="True" />
            </Trigger>
            <Trigger Property="Role" Value="SubmenuHeader">
                <Setter Property="Background" Value="{DynamicResource MenuFlyoutSubItemBackground}" />
                <Setter Property="BorderBrush" Value="{DynamicResource MenuFlyoutSubItemBackgroundBrush}" />
                <Setter Property="BorderThickness" Value="{DynamicResource MenuFlyoutSubItemBorderThickness}"/>
                <Setter Property="Foreground" Value="{DynamicResource MenuFlyoutSubItemForeground}" />
                <Setter Property="Template" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=SubmenuHeaderTemplateKey}}" />
            </Trigger>
            <Trigger Property="IsCheckable" Value="True">
                <Setter Property="Background" Value="Transparent" />
                <Setter Property="primitives:FocusVisualHelper.UseSystemFocusVisuals" Value="True" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="MenuItem" BasedOn="{StaticResource DefaultMenuItemStyle}" />

</ResourceDictionary>