ListBoxItemToolBar.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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.Input;
  9. namespace PDF_Master.CustomControl
  10. {
  11. public class ListItemQuickTool : ListBoxItem
  12. {
  13. // 属性的定义与注册
  14. public static DependencyProperty IsOverModularProperty = DependencyProperty.Register("IsOverModular", typeof(bool), typeof(ListItemQuickTool), new PropertyMetadata(false));
  15. // 属性的包装
  16. public bool IsOverModular
  17. {
  18. get { return (bool)GetValue(IsOverModularProperty); }
  19. set { SetValue(IsOverModularProperty, value); }
  20. }
  21. protected override void OnDragEnter(DragEventArgs e)
  22. {
  23. base.OnDragEnter(e);
  24. IsOverModular = true;
  25. }
  26. protected override void OnDragLeave(DragEventArgs e)
  27. {
  28. base.OnDragLeave(e);
  29. IsOverModular = false;
  30. }
  31. protected override void OnDragOver(DragEventArgs e)
  32. {
  33. base.OnDragOver(e);
  34. IsOverModular = true;
  35. }
  36. protected override void OnDrop(DragEventArgs e)
  37. {
  38. base.OnDrop(e);
  39. IsOverModular = false;
  40. }
  41. protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e)
  42. {
  43. base.OnPreviewMouseLeftButtonUp(e);
  44. }
  45. }
  46. public class ListBoxEx : ListBox
  47. {
  48. protected override DependencyObject GetContainerForItemOverride() => new ListItemQuickTool();
  49. }
  50. }