<UserControl x:Class="ControlCatalog.Pages.ContextMenuPage"
             xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <StackPanel Orientation="Vertical" Spacing="4">
    <TextBlock Classes="h2">A right click menu that can be applied to any control.</TextBlock>

    <UniformGrid HorizontalAlignment="Center" Rows="2">
      <UniformGrid.Styles>
        <Style Selector="UniformGrid > Border">
          <Setter Property="Padding" Value="48,20" />
          <Setter Property="Margin" Value="8" />
          <Setter Property="Focusable" Value="True" />
          <Setter Property="Background" Value="{DynamicResource SystemAccentColor}" />
        </Style>
        <Style Selector="UniformGrid > Border > :is(Control)">
          <Setter Property="VerticalAlignment" Value="Center" />
        </Style>
      </UniformGrid.Styles>
      <Border>
        <Border.ContextMenu>
          <ContextMenu>
            <MenuItem Header="Standard _Menu Item" InputGesture="Ctrl+A" />
            <MenuItem Header="_Disabled Menu Item"
                      InputGesture="Ctrl+D"
                      IsEnabled="False" />
            <Separator />
            <MenuItem Header="Menu with _Submenu">
              <MenuItem Header="Submenu _1" />
              <MenuItem Header="Submenu _2" />
            </MenuItem>
            <MenuItem Header="Menu Item with _Icon" InputGesture="Ctrl+Shift+B">
              <MenuItem.Icon>
                <Image Source="/Assets/github_icon.png" />
              </MenuItem.Icon>
            </MenuItem>
            <MenuItem Header="Menu Item with _Checkbox">
              <MenuItem.Icon>
                <CheckBox BorderThickness="0"
                          IsChecked="True"
                          IsHitTestVisible="False" />
              </MenuItem.Icon>
            </MenuItem>
            <MenuItem Header="Menu Item that won't close on click" StaysOpenOnClick="True" />
          </ContextMenu>
        </Border.ContextMenu>
        <TextBlock Text="Defined in XAML" />
      </Border>
      <Border>
        <Border.Styles>
          <Style Selector="ContextMenu MenuItem">
            <Setter Property="Header" Value="{Binding Header}"/>
            <Setter Property="Items" Value="{Binding Items}"/>
            <Setter Property="Command" Value="{Binding Command}"/>
            <Setter Property="CommandParameter" Value="{Binding CommandParameter}"/>
          </Style>
        </Border.Styles>
        <Border.ContextMenu>
          <ContextMenu Items="{Binding MenuItems}" />
        </Border.ContextMenu>
        <TextBlock Text="Dynamically Generated"/>
      </Border>
      <Border x:Name="CustomContextRequestedBorder">
        <Border.ContextMenu>
          <ContextMenu>
            <MenuItem Header="Should never be visible" />
          </ContextMenu>
        </Border.ContextMenu>
        <TextBlock Text="Custom ContextRequested handler" TextWrapping="Wrap" />
      </Border>
      <Border x:Name="CancellableContextBorder">
        <Border.ContextMenu>
          <ContextMenu>
            <MenuItem>
              <MenuItem.Header>
                <CheckBox x:Name="CancelCloseCheckBox" Content="Cancel close" />
              </MenuItem.Header>
            </MenuItem>
          </ContextMenu>
        </Border.ContextMenu>
        <StackPanel>
          <TextBlock Text="Cancellable" />
          <CheckBox x:Name="CancelOpenCheckBox" Content="Cancel open" />
        </StackPanel>
      </Border>
    </UniformGrid>
  </StackPanel>
</UserControl>
