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

  <ControlTheme x:Key="TopLevelMenuItem"
                TargetType="MenuItem">
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="Padding" Value="7 4" />
    <Setter Property="BorderThickness" Value="1" />
    <Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}"/>
    <Setter Property="Template">
      <ControlTemplate>
        <Border Name="root"
                Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                CornerRadius="{TemplateBinding CornerRadius}">
          <Panel>
            <ContentPresenter Name="PART_HeaderPresenter"
                              Margin="{TemplateBinding Padding}"
                              Content="{TemplateBinding Header}"
                              ContentTemplate="{TemplateBinding HeaderTemplate}">
              <ContentPresenter.DataTemplates>
                <DataTemplate DataType="sys:String">
                  <AccessText Text="{Binding}" />
                </DataTemplate>
              </ContentPresenter.DataTemplates>
            </ContentPresenter>
            <Popup Name="PART_Popup"
                   IsLightDismissEnabled="True"
                   IsOpen="{TemplateBinding IsSubMenuOpen, Mode=TwoWay}"
                   Placement="BottomEdgeAlignedLeft"
                   OverlayInputPassThroughElement="{Binding $parent[Menu]}">
              <Border Background="{DynamicResource ThemeBackgroundBrush}"
                      BorderBrush="{DynamicResource ThemeBorderMidBrush}"
                      CornerRadius="{DynamicResource ControlCornerRadius}"
                      BorderThickness="{TemplateBinding BorderThickness}">
                <ScrollViewer>
                  <ItemsPresenter Name="PART_ItemsPresenter"
                                  Margin="2"
                                  Grid.IsSharedSizeScope="True"
                                  ItemsPanel="{TemplateBinding ItemsPanel}" />
                </ScrollViewer>
              </Border>
            </Popup>
          </Panel>
        </Border>
      </ControlTemplate>
    </Setter>

    <Style Selector="^:selected /template/ Border#root">
        <Setter Property="Background" Value="{DynamicResource ThemeControlHighBrush}" />
    </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 x:Key="{x:Type Menu}"
                TargetType="Menu">
    <Setter Property="ItemContainerTheme" Value="{StaticResource TopLevelMenuItem}" />
    <Setter Property="Template">
      <ControlTemplate>
        <Border Padding="{TemplateBinding Padding}"
                Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                CornerRadius="{TemplateBinding CornerRadius}">
          <ItemsPresenter Name="PART_ItemsPresenter"
                          ItemsPanel="{TemplateBinding ItemsPanel}"
                          KeyboardNavigation.TabNavigation="Continue" />
        </Border>
      </ControlTemplate>
    </Setter>
  </ControlTheme>
</ResourceDictionary>