RibbonGroup.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System.Windows;
  2. using System.Windows.Controls;
  3. using System.Windows.Input;
  4. using HandyControl.Data;
  5. using HandyControl.Interactivity;
  6. namespace HandyControl.Controls
  7. {
  8. public class RibbonGroup : HeaderedItemsControl
  9. {
  10. public RibbonGroup()
  11. {
  12. CommandBindings.Add(new CommandBinding(ControlCommands.More, LauncherButton_OnClick));
  13. }
  14. private void LauncherButton_OnClick(object sender, ExecutedRoutedEventArgs e)
  15. {
  16. OnLauncherClick(new RoutedEventArgs(LauncherClickEvent, this));
  17. }
  18. public static readonly DependencyProperty ShowLauncherButtonProperty = DependencyProperty.Register(
  19. nameof(ShowLauncherButton), typeof(bool), typeof(RibbonGroup), new PropertyMetadata(ValueBoxes.FalseBox));
  20. public bool ShowLauncherButton
  21. {
  22. get => (bool) GetValue(ShowLauncherButtonProperty);
  23. set => SetValue(ShowLauncherButtonProperty, value);
  24. }
  25. public static readonly DependencyProperty ShowSplitterProperty = DependencyProperty.Register(
  26. nameof(ShowSplitter), typeof(bool), typeof(RibbonGroup), new PropertyMetadata(ValueBoxes.TrueBox));
  27. public bool ShowSplitter
  28. {
  29. get => (bool) GetValue(ShowSplitterProperty);
  30. set => SetValue(ShowSplitterProperty, value);
  31. }
  32. public static readonly DependencyProperty LauncherPoptipProperty = DependencyProperty.Register(
  33. nameof(LauncherPoptip), typeof(Poptip), typeof(RibbonGroup), new PropertyMetadata(default(Poptip)));
  34. public Poptip LauncherPoptip
  35. {
  36. get => (Poptip) GetValue(LauncherPoptipProperty);
  37. set => SetValue(LauncherPoptipProperty, value);
  38. }
  39. public static readonly RoutedEvent LauncherClickEvent =
  40. EventManager.RegisterRoutedEvent("LauncherClick", RoutingStrategy.Bubble,
  41. typeof(RoutedEventHandler), typeof(RibbonGroup));
  42. public event RoutedEventHandler LauncherClick
  43. {
  44. add => AddHandler(LauncherClickEvent, value);
  45. remove => RemoveHandler(LauncherClickEvent, value);
  46. }
  47. protected virtual void OnLauncherClick(RoutedEventArgs e) => RaiseEvent(e);
  48. }
  49. }