using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Input; namespace PDF_Office.CustomControl { public class ListItemQuickTool : ListBoxItem { // 属性的定义与注册 public static DependencyProperty IsOverModularProperty = DependencyProperty.Register("IsOverModular", typeof(bool), typeof(ListItemQuickTool), new PropertyMetadata(false)); // 属性的包装 public bool IsOverModular { get { return (bool)GetValue(IsOverModularProperty); } set { SetValue(IsOverModularProperty, value); } } protected override void OnDragEnter(DragEventArgs e) { base.OnDragEnter(e); IsOverModular = true; } protected override void OnDragLeave(DragEventArgs e) { base.OnDragLeave(e); IsOverModular = false; } protected override void OnDragOver(DragEventArgs e) { base.OnDragOver(e); IsOverModular = true; } protected override void OnDrop(DragEventArgs e) { base.OnDrop(e); IsOverModular = false; } protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e) { base.OnPreviewMouseLeftButtonUp(e); } } public class ListBoxEx : ListBox { protected override DependencyObject GetContainerForItemOverride() => new ListItemQuickTool(); } }