1
0

CommandBarCustomizationPage.xaml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <UserControl xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. x:Class="ControlCatalog.Pages.CommandBarCustomizationPage">
  4. <UserControl.Resources>
  5. <StreamGeometry x:Key="AddIcon">M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z</StreamGeometry>
  6. <StreamGeometry x:Key="SaveIcon">M15,9H5V5H15M12,19A3,3 0 0,1 9,16A3,3 0 0,1 12,13A3,3 0 0,1 15,16A3,3 0 0,1 12,19M17,3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V7L17,3Z</StreamGeometry>
  7. <StreamGeometry x:Key="ShareIcon">M18,16.08C17.24,16.08 16.56,16.38 16.04,16.85L8.91,12.7C8.96,12.47 9,12.24 9,12C9,11.76 8.96,11.53 8.91,11.3L15.96,7.19C16.5,7.69 17.21,8 18,8A3,3 0 0,0 21,5A3,3 0 0,0 18,2A3,3 0 0,0 15,5C15,5.24 15.04,5.47 15.09,5.7L8.04,9.81C7.5,9.31 6.79,9 6,9A3,3 0 0,0 3,12A3,3 0 0,0 6,15C6.79,15 7.5,14.69 8.04,14.19L15.16,18.34C15.11,18.55 15.08,18.77 15.08,19C15.08,20.61 16.39,21.91 18,21.91C19.61,21.91 20.92,20.61 20.92,19C20.92,17.39 19.61,16.08 18,16.08Z</StreamGeometry>
  8. </UserControl.Resources>
  9. <DockPanel>
  10. <ScrollViewer DockPanel.Dock="Right" Width="260">
  11. <StackPanel Margin="12" Spacing="8">
  12. <TextBlock Text="Configuration" FontWeight="SemiBold" FontSize="16"
  13. Foreground="{DynamicResource SystemControlHighlightAccentBrush}" />
  14. <TextBlock Text="Live Preview" FontWeight="SemiBold" FontSize="13" />
  15. <CommandBar x:Name="LiveBar">
  16. <CommandBar.PrimaryCommands>
  17. <CommandBarButton Label="New"><CommandBarButton.Icon><PathIcon Data="{StaticResource AddIcon}" /></CommandBarButton.Icon></CommandBarButton>
  18. <CommandBarButton Label="Save"><CommandBarButton.Icon><PathIcon Data="{StaticResource SaveIcon}" /></CommandBarButton.Icon></CommandBarButton>
  19. <CommandBarButton Label="Share"><CommandBarButton.Icon><PathIcon Data="{StaticResource ShareIcon}" /></CommandBarButton.Icon></CommandBarButton>
  20. </CommandBar.PrimaryCommands>
  21. </CommandBar>
  22. <Separator />
  23. <TextBlock Text="Background Preset" />
  24. <ComboBox x:Name="BgPresetCombo"
  25. SelectedIndex="0"
  26. HorizontalAlignment="Stretch"
  27. SelectionChanged="OnBgPresetChanged">
  28. <ComboBoxItem Content="Default" />
  29. <ComboBoxItem Content="Blue (#0078D4)" />
  30. <ComboBoxItem Content="Dark (#1C1C1E)" />
  31. <ComboBoxItem Content="Gradient" />
  32. <ComboBoxItem Content="Transparent" />
  33. </ComboBox>
  34. <TextBlock Text="Foreground" />
  35. <ComboBox x:Name="FgCombo"
  36. SelectedIndex="0"
  37. HorizontalAlignment="Stretch"
  38. SelectionChanged="OnFgChanged">
  39. <ComboBoxItem Content="Default" />
  40. <ComboBoxItem Content="White" />
  41. <ComboBoxItem Content="Black" />
  42. </ComboBox>
  43. <TextBlock Text="Corner Radius" />
  44. <Slider x:Name="RadiusSlider"
  45. Minimum="0"
  46. Maximum="24"
  47. Value="0"
  48. ValueChanged="OnRadiusChanged" />
  49. <TextBlock x:Name="RadiusLabel"
  50. Text="0"
  51. HorizontalAlignment="Center"
  52. Opacity="0.7" />
  53. <TextBlock Text="Border Thickness" />
  54. <Slider x:Name="BorderSlider"
  55. Minimum="0"
  56. Maximum="4"
  57. Value="0"
  58. TickFrequency="1"
  59. IsSnapToTickEnabled="True"
  60. ValueChanged="OnBorderChanged" />
  61. <TextBlock x:Name="BorderLabel"
  62. Text="0"
  63. HorizontalAlignment="Center"
  64. Opacity="0.7" />
  65. <Separator />
  66. <TextBlock Text="About" FontWeight="SemiBold" />
  67. <TextBlock Text="CommandBar inherits from TemplatedControl, so Background, Foreground, BorderBrush, BorderThickness, and CornerRadius are available out of the box."
  68. FontSize="12" Opacity="0.7" TextWrapping="Wrap" />
  69. <TextBlock Text="Foreground is an inherited property: setting it on the CommandBar cascades to all PathIcons inside CommandBarButton/CommandBarToggleButton."
  70. FontSize="12" Opacity="0.7" TextWrapping="Wrap" Margin="0,4,0,0" />
  71. </StackPanel>
  72. </ScrollViewer>
  73. <Border DockPanel.Dock="Right" Width="1" Background="{DynamicResource SystemControlForegroundBaseMediumLowBrush}" />
  74. <ScrollViewer>
  75. <StackPanel Spacing="16" Margin="12,12,12,0">
  76. <TextBlock Classes="h2">Customize the CommandBar appearance using Background, Foreground, BorderBrush, and CornerRadius.</TextBlock>
  77. <TextBlock Text="Style Presets" FontWeight="SemiBold" />
  78. <TextBlock Text="Default theme" FontSize="12" Opacity="0.7" />
  79. <CommandBar OverflowButtonVisibility="Collapsed">
  80. <CommandBarButton Label="New"><CommandBarButton.Icon><PathIcon Data="{StaticResource AddIcon}" /></CommandBarButton.Icon></CommandBarButton>
  81. <CommandBarButton Label="Save"><CommandBarButton.Icon><PathIcon Data="{StaticResource SaveIcon}" /></CommandBarButton.Icon></CommandBarButton>
  82. </CommandBar>
  83. <TextBlock Text="Solid color" FontSize="12" Opacity="0.7" />
  84. <CommandBar Background="#0078D4" Foreground="White" OverflowButtonVisibility="Collapsed">
  85. <CommandBarButton Label="New"><CommandBarButton.Icon><PathIcon Data="{StaticResource AddIcon}" /></CommandBarButton.Icon></CommandBarButton>
  86. <CommandBarButton Label="Save"><CommandBarButton.Icon><PathIcon Data="{StaticResource SaveIcon}" /></CommandBarButton.Icon></CommandBarButton>
  87. </CommandBar>
  88. <TextBlock Text="Dark" FontSize="12" Opacity="0.7" />
  89. <CommandBar Background="#1C1C1E" Foreground="White" OverflowButtonVisibility="Collapsed">
  90. <CommandBarButton Label="New"><CommandBarButton.Icon><PathIcon Data="{StaticResource AddIcon}" /></CommandBarButton.Icon></CommandBarButton>
  91. <CommandBarButton Label="Save"><CommandBarButton.Icon><PathIcon Data="{StaticResource SaveIcon}" /></CommandBarButton.Icon></CommandBarButton>
  92. </CommandBar>
  93. <TextBlock Text="Pill shape (CornerRadius=20)" FontSize="12" Opacity="0.7" />
  94. <CommandBar Background="#F0F0F0"
  95. CornerRadius="20"
  96. BorderBrush="#CCCCCC"
  97. BorderThickness="1"
  98. OverflowButtonVisibility="Collapsed">
  99. <CommandBarButton Label="New"><CommandBarButton.Icon><PathIcon Data="{StaticResource AddIcon}" /></CommandBarButton.Icon></CommandBarButton>
  100. <CommandBarButton Label="Save"><CommandBarButton.Icon><PathIcon Data="{StaticResource SaveIcon}" /></CommandBarButton.Icon></CommandBarButton>
  101. </CommandBar>
  102. </StackPanel>
  103. </ScrollViewer>
  104. </DockPanel>
  105. </UserControl>