<Style xmlns="https://github.com/avaloniaui"
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       xmlns:local="clr-namespace:Avalonia.Themes.Default"
       Selector="NativeMenuBar">
  <Style.Resources>
    <local:InverseBooleanValueConverter x:Key="AvaloniaThemesDefaultNativeMenuBarInverseBooleanValueConverter" Default="True"/>
    <local:IBitmapToImageConverter x:Key="AvaloniaThemesDefaultNativeMenuBarIBitmapToImageConverterr"/>
  </Style.Resources>
  <Setter Property="Template">
    <ControlTemplate>
      <Menu
        IsVisible="{Binding $parent[TopLevel].(NativeMenu.IsNativeMenuExported), Converter={StaticResource AvaloniaThemesDefaultNativeMenuBarInverseBooleanValueConverter}}"
        Items="{Binding $parent[TopLevel].(NativeMenu.Menu).Items}">
        <Menu.Styles>
          <Style Selector="MenuItem">
            <Setter Property="Header" Value="{Binding Header}"/>
            <Setter Property="InputGesture" Value="{Binding Gesture}"/>
            <Setter Property="Items" Value="{Binding Menu.Items}"/>
            <Setter Property="Command" Value="{Binding Command}"/>
            <Setter Property="CommandParameter" Value="{Binding CommandParameter}"/>
            <Setter Property="(NativeMenuBar.EnableMenuItemClickForwarding)" Value="True"/>
            <!--NativeMenuItem is IBitmap and MenuItem is Image-->
            <Setter Property="Icon" Value="{Binding Icon , Converter={StaticResource AvaloniaThemesDefaultNativeMenuBarIBitmapToImageConverterr}}"/>
          </Style>
        </Menu.Styles>
      </Menu>
    </ControlTemplate>
  </Setter>
</Style>
