MenuPage.xaml 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <UserControl xmlns="https://github.com/avaloniaui">
  2. <StackPanel Orientation="Vertical" Spacing="4">
  3. <TextBlock Classes="h1">Menu</TextBlock>
  4. <TextBlock Classes="h2">A window menu</TextBlock>
  5. <StackPanel Orientation="Horizontal"
  6. Margin="0,16,0,0"
  7. HorizontalAlignment="Center"
  8. Spacing="16">
  9. <StackPanel>
  10. <TextBlock Classes="h3" Margin="4 8">Defined in XAML</TextBlock>
  11. <Menu>
  12. <MenuItem Header="_First">
  13. <MenuItem Header="Standard _Menu Item"/>
  14. <Separator/>
  15. <MenuItem Header="Menu with _Submenu">
  16. <MenuItem Header="Submenu _1"/>
  17. <MenuItem Header="Submenu _2"/>
  18. </MenuItem>
  19. <MenuItem Header="Menu Item with _Icon">
  20. <MenuItem.Icon>
  21. <Image Source="resm:ControlCatalog.Assets.github_icon.png"/>
  22. </MenuItem.Icon>
  23. </MenuItem>
  24. <MenuItem Header="Menu Item with _Checkbox">
  25. <MenuItem.Icon>
  26. <CheckBox BorderThickness="0" IsHitTestVisible="False" IsChecked="True"/>
  27. </MenuItem.Icon>
  28. </MenuItem>
  29. </MenuItem>
  30. <MenuItem Header="_Second">
  31. <MenuItem Header="Second _Menu Item"/>
  32. </MenuItem>
  33. </Menu>
  34. </StackPanel>
  35. <StackPanel>
  36. <TextBlock Classes="h3" Margin="4 8">Dyanamically generated</TextBlock>
  37. <Menu Items="{Binding MenuItems}">
  38. <Menu.Styles>
  39. <Style Selector="MenuItem">
  40. <Setter Property="Header" Value="{Binding Header}"/>
  41. <Setter Property="Items" Value="{Binding Items}"/>
  42. <Setter Property="Command" Value="{Binding Command}"/>
  43. <Setter Property="CommandParameter" Value="{Binding CommandParameter}"/>
  44. </Style>
  45. </Menu.Styles>
  46. </Menu>
  47. </StackPanel>
  48. </StackPanel>
  49. </StackPanel>
  50. </UserControl>