<ResourceDictionary
    x:ClassModifier="internal"
    xmlns="https://github.com/avaloniaui"
    xmlns:sys="using:System"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <ControlTheme TargetType="MenuItem" x:Key="SimpleTopLevelMenuItem">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Padding" Value="6 0" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Template">
            <ControlTemplate>

                <Border
                    Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    CornerRadius="{TemplateBinding CornerRadius}"
                    Name="root">
                    <Panel>
                        <ContentPresenter
                            Content="{TemplateBinding Header}"
                            ContentTemplate="{TemplateBinding HeaderTemplate}"
                            Margin="{TemplateBinding Padding}"
                            Name="PART_HeaderPresenter"
                            VerticalAlignment="Center">
                            <ContentPresenter.DataTemplates>
                                <DataTemplate DataType="sys:String">
                                    <AccessText Text="{Binding}" />
                                </DataTemplate>
                            </ContentPresenter.DataTemplates>
                        </ContentPresenter>
                        <Popup
                            IsLightDismissEnabled="True"
                            IsOpen="{TemplateBinding IsSubMenuOpen,
                                                     Mode=TwoWay}"
                            Name="PART_Popup"
                            OverlayInputPassThroughElement="{Binding $parent[Menu]}"
                            Placement="BottomEdgeAlignedLeft">
                            <Border
                                Background="{DynamicResource MainBackgroundColor}"
                                BorderBrush="{DynamicResource MainBorderColor}"
                                BorderThickness="1">
                                <ItemsPresenter
                                    Grid.IsSharedSizeScope="True"
                                    ItemsPanel="{TemplateBinding ItemsPanel}"
                                    Margin="2"
                                    Name="PART_ItemsPresenter" />
                            </Border>
                        </Popup>
                    </Panel>
                </Border>
            </ControlTemplate>
        </Setter>

        <Style Selector="^:selected /template/ Border#root">
            <Setter Property="Background" Value="{DynamicResource AccentColor}" />
        </Style>

        <Style Selector="^:selected /template/ ContentPresenter#PART_HeaderPresenter">
            <Setter Property="Foreground" Value="{StaticResource SecondaryTextColor}" />
        </Style>

        <Style Selector="^:empty /template/ Path#rightArrow">
            <Setter Property="IsVisible" Value="False" />
        </Style>

        <Style Selector="^:disabled">
            <Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}" />
        </Style>
    </ControlTheme>

    <ControlTheme TargetType="Menu" x:Key="{x:Type Menu}">
        <Setter Property="ItemContainerTheme" Value="{StaticResource SimpleTopLevelMenuItem}" />
        <Setter Property="Template">
            <ControlTemplate>

                <Border
                    Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    CornerRadius="{TemplateBinding CornerRadius}"
                    Padding="{TemplateBinding Padding}">
                    <ItemsPresenter
                        ItemsPanel="{TemplateBinding ItemsPanel}"
                        KeyboardNavigation.TabNavigation="Continue"
                        Name="PART_ItemsPresenter" />
                </Border>
            </ControlTemplate>
        </Setter>
    </ControlTheme>
</ResourceDictionary>