MenuItemWithPath.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Media;
  9. namespace PDF_Office.CustomControl
  10. {
  11. /// <summary>
  12. /// 带Path图案的Menuitem 图案颜色跟随文字颜色变化
  13. /// </summary>
  14. public class MenuItemWithPath:MenuItem
  15. {
  16. static MenuItemWithPath()
  17. {
  18. DefaultStyleKeyProperty.OverrideMetadata(typeof(MenuItemWithPath), new FrameworkPropertyMetadata(typeof(MenuItemWithPath)));
  19. }
  20. public override void OnApplyTemplate()
  21. {
  22. base.OnApplyTemplate();
  23. }
  24. public Geometry Path
  25. {
  26. get { return (Geometry)GetValue(PathProperty); }
  27. set { SetValue(PathProperty, value); }
  28. }
  29. // Using a DependencyProperty as the backing store for Path. This enables animation, styling, binding, etc...
  30. public static readonly DependencyProperty PathProperty =
  31. DependencyProperty.Register("Path", typeof(Geometry), typeof(MenuItemWithPath), null);
  32. public double PathWidth
  33. {
  34. get { return (double)GetValue(PathWidthProperty); }
  35. set { SetValue(PathWidthProperty, value); }
  36. }
  37. // Using a DependencyProperty as the backing store for PathWidth. This enables animation, styling, binding, etc...
  38. public static readonly DependencyProperty PathWidthProperty =
  39. DependencyProperty.Register("PathWidth", typeof(double), typeof(MenuItemWithPath), new PropertyMetadata(16.0));
  40. public double PathHeight
  41. {
  42. get { return (double)GetValue(PathHeightProperty); }
  43. set { SetValue(PathHeightProperty, value); }
  44. }
  45. // Using a DependencyProperty as the backing store for PathHeight. This enables animation, styling, binding, etc...
  46. public static readonly DependencyProperty PathHeightProperty =
  47. DependencyProperty.Register("PathHeight", typeof(double), typeof(MenuItemWithPath), new PropertyMetadata(16.0));
  48. }
  49. }