CommandBarTogglePage.xaml 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <UserControl xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. x:Class="ControlCatalog.Pages.CommandBarTogglePage">
  4. <UserControl.Resources>
  5. <StreamGeometry x:Key="BoldIcon">M15.6,10.79C17.04,10.07 18,8.64 18,7C18,4.79 16.21,3 14,3H7V21H14.73C16.78,21 18.5,19.37 18.5,17.32C18.5,15.82 17.72,14.53 16.5,13.77C16.2,13.59 15.9,13.44 15.6,13.32V10.79M10,6.5H13C13.83,6.5 14.5,7.17 14.5,8C14.5,8.83 13.83,9.5 13,9.5H10V6.5M13.5,17.5H10V14H13.5C14.33,14 15,14.67 15,15.5C15,16.33 14.33,17.5 13.5,17.5Z</StreamGeometry>
  6. <StreamGeometry x:Key="ItalicIcon">M10,4V7H12.21L8.79,15H6V18H14V15H11.79L15.21,7H18V4H10Z</StreamGeometry>
  7. <StreamGeometry x:Key="UnderlineIcon">M5,21H19V19H5V21M12,17A6,6 0 0,0 18,11V3H15.5V11A3.5,3.5 0 0,1 12,14.5A3.5,3.5 0 0,1 8.5,11V3H6V11A6,6 0 0,0 12,17Z</StreamGeometry>
  8. <StreamGeometry x:Key="FavoriteIcon">M12,21.35L10.55,20.03C5.4,15.36 2,12.27 2,8.5C2,5.41 4.42,3 7.5,3C9.24,3 10.91,3.81 12,5.08C13.09,3.81 14.76,3 16.5,3C19.58,3 22,5.41 22,8.5C22,12.27 18.6,15.36 13.45,20.03L12,21.35Z</StreamGeometry>
  9. </UserControl.Resources>
  10. <DockPanel>
  11. <ScrollViewer DockPanel.Dock="Right" Width="260">
  12. <StackPanel Margin="12" Spacing="8">
  13. <TextBlock Text="Configuration" FontWeight="SemiBold" FontSize="16"
  14. Foreground="{DynamicResource SystemControlHighlightAccentBrush}" />
  15. <TextBlock Text="Toggle State" FontWeight="SemiBold" FontSize="13" />
  16. <CheckBox x:Name="ForceBoldCheck"
  17. Content="Bold"
  18. IsCheckedChanged="OnForceBoldChanged" />
  19. <CheckBox x:Name="ForceItalicCheck"
  20. Content="Italic"
  21. IsCheckedChanged="OnForceItalicChanged" />
  22. <CheckBox x:Name="ForceUnderlineCheck"
  23. Content="Underline"
  24. IsCheckedChanged="OnForceUnderlineChanged" />
  25. <Separator />
  26. <TextBlock Text="About" FontWeight="SemiBold" />
  27. <TextBlock Text="CommandBarToggleButton maintains checked/unchecked state. When checked, it shows a highlight background. Bind IsChecked to a boolean property."
  28. FontSize="12" Opacity="0.7" TextWrapping="Wrap" />
  29. </StackPanel>
  30. </ScrollViewer>
  31. <Border DockPanel.Dock="Right" Width="1" Background="{DynamicResource SystemControlForegroundBaseMediumLowBrush}" />
  32. <ScrollViewer>
  33. <StackPanel Spacing="12" Margin="12,12,12,0">
  34. <TextBlock Classes="h2">CommandBarToggleButton supports on/off states for formatting and feature toggles.</TextBlock>
  35. <TextBlock Text="Text Formatting" FontWeight="SemiBold" />
  36. <CommandBar x:Name="FormatBar" OverflowButtonVisibility="Collapsed">
  37. <CommandBarToggleButton x:Name="BoldToggle"
  38. Label="Bold"
  39. IsCheckedChanged="OnFormatChanged">
  40. <CommandBarToggleButton.Icon><PathIcon Data="{StaticResource BoldIcon}" /></CommandBarToggleButton.Icon>
  41. </CommandBarToggleButton>
  42. <CommandBarToggleButton x:Name="ItalicToggle"
  43. Label="Italic"
  44. IsCheckedChanged="OnFormatChanged">
  45. <CommandBarToggleButton.Icon><PathIcon Data="{StaticResource ItalicIcon}" /></CommandBarToggleButton.Icon>
  46. </CommandBarToggleButton>
  47. <CommandBarToggleButton x:Name="UnderlineToggle"
  48. Label="Underline"
  49. IsCheckedChanged="OnFormatChanged">
  50. <CommandBarToggleButton.Icon><PathIcon Data="{StaticResource UnderlineIcon}" /></CommandBarToggleButton.Icon>
  51. </CommandBarToggleButton>
  52. </CommandBar>
  53. <TextBlock x:Name="FormatStatus"
  54. Text="Active: (none)"
  55. FontSize="13"
  56. Opacity="0.7" />
  57. <Separator />
  58. <TextBlock Text="Favorite" FontWeight="SemiBold" />
  59. <CommandBar OverflowButtonVisibility="Collapsed">
  60. <CommandBarToggleButton Label="Favorite">
  61. <CommandBarToggleButton.Icon><PathIcon Data="{StaticResource FavoriteIcon}" /></CommandBarToggleButton.Icon>
  62. </CommandBarToggleButton>
  63. </CommandBar>
  64. </StackPanel>
  65. </ScrollViewer>
  66. </DockPanel>
  67. </UserControl>