<Style xmlns="https://github.com/avaloniaui"
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       Selector="ContextMenu">
  <Design.PreviewWith>
    <Border Background="{DynamicResource SystemAccentColor}"
            Margin="16"
            Padding="48"
            Width="400"
            Height="200">
      <Border.ContextMenu>
        <ContextMenu>
          <MenuItem Header="Standard _Menu Item" />
          <MenuItem Header="Disabled"
                    IsEnabled="False" />
          <Separator />
          <MenuItem Header="Menu with _Submenu">
            <MenuItem Header="Submenu _1" />
            <MenuItem Header="Submenu _2" />
          </MenuItem>
          <MenuItem Header="Menu Item with _Icon" />
          <MenuItem Header="Menu Item with _Checkbox">
            <MenuItem.Icon>
              <CheckBox BorderThickness="0"
                        IsHitTestVisible="False"
                        IsChecked="True" />
            </MenuItem.Icon>
          </MenuItem>
        </ContextMenu>
      </Border.ContextMenu>
      <TextBlock Text="Defined in XAML" />
    </Border>
  </Design.PreviewWith>

  <Style.Resources>
    <!-- Added missing resource -->
    <Thickness x:Key="MenuFlyoutScrollerMargin">0,4,0,4</Thickness>
  </Style.Resources>

  <Setter Property="Background" Value="{DynamicResource MenuFlyoutPresenterBackground}" />
  <Setter Property="BorderBrush" Value="{DynamicResource MenuFlyoutPresenterBorderBrush}" />
  <Setter Property="BorderThickness" Value="{DynamicResource MenuFlyoutPresenterBorderThemeThickness}" />
  <Setter Property="CornerRadius" Value="{DynamicResource OverlayCornerRadius}" />
  <Setter Property="MaxWidth" Value="{DynamicResource FlyoutThemeMaxWidth}" />
  <Setter Property="MinHeight" Value="{DynamicResource MenuFlyoutThemeMinHeight}" />
  <Setter Property="Padding" Value="{DynamicResource MenuFlyoutPresenterThemePadding}" />
  <Setter Property="HorizontalAlignment" Value="Stretch" />
  <Setter Property="TextBlock.FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
  <Setter Property="TextBlock.FontWeight" Value="Normal" />
  <Setter Property="WindowManagerAddShadowHint" Value="False" />
  <Setter Property="Template">
    <ControlTemplate>
      <Border Background="{TemplateBinding Background}"
              BorderBrush="{TemplateBinding BorderBrush}"
              BorderThickness="{TemplateBinding BorderThickness}"
              Padding="{TemplateBinding Padding}"
              MaxWidth="{TemplateBinding MaxWidth}"
              MinHeight="{TemplateBinding MinHeight}"
              HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
              CornerRadius="{TemplateBinding CornerRadius}">
        <ScrollViewer Classes="menuscroller">
          <ItemsPresenter Name="PART_ItemsPresenter"
                          Items="{TemplateBinding Items}"
                          ItemsPanel="{TemplateBinding ItemsPanel}"
                          ItemTemplate="{TemplateBinding ItemTemplate}"
                          Margin="{DynamicResource MenuFlyoutScrollerMargin}"
                          KeyboardNavigation.TabNavigation="Continue"
                          Grid.IsSharedSizeScope="True" />
        </ScrollViewer>
      </Border>
    </ControlTemplate>
  </Setter>
</Style>
