From f36cdaff7e05a9326d3d5abb21bc88f4d760c43d Mon Sep 17 00:00:00 2001 From: fyf Date: Sat, 15 Oct 2022 13:55:00 +0800 Subject: [PATCH] 1 --- WPFDemo/TheListBox.xaml.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/WPFDemo/TheListBox.xaml.cs b/WPFDemo/TheListBox.xaml.cs index a95547a4..9b016e32 100644 --- a/WPFDemo/TheListBox.xaml.cs +++ b/WPFDemo/TheListBox.xaml.cs @@ -149,7 +149,9 @@ namespace WPFDemo DropPopup.HorizontalOffset = ptLeftUp.X + x - ((FrameworkElement)ChildElement).ActualWidth / 2; DropPopup.VerticalOffset = ptLeftUp.Y + y - ((FrameworkElement)ChildElement).ActualHeight / 2; } - MoveListBoxStyle(e,true); + + //蒙层打开,表明拖拽开始,设置透明度和显示状态 + MoveListBoxStyle(e, true); } catch (Exception ex) { @@ -159,7 +161,7 @@ namespace WPFDemo /// 移动效果 /// /// - private void MoveListBoxStyle(MouseEventArgs e,bool isBool) + private void MoveListBoxStyle(MouseEventArgs e, bool isBool) { try { @@ -170,12 +172,10 @@ namespace WPFDemo { if (item != ChildListBoxItem)//这就是其他控件 { - double item_width = item.ActualWidth; - double item_height = item.ActualHeight; - double item_x = e.GetPosition(item).X; - double item_y = e.GetPosition(item).Y; - double Child_x = e.GetPosition(ChildElement).X; - double Child_y = e.GetPosition(ChildElement).Y; + double item_width = item.ActualWidth; //当前行宽 + double item_height = item.ActualHeight; //当前行高 + double item_x = e.GetPosition(item).X; //鼠标相对当前行X位移 + double item_y = e.GetPosition(item).Y; //鼠标相对当前行Y位移 if (item_y <= item_height && item_y > 0 && item_x > 0 && item_x <= item_width)//鼠标进入哪一行,则将那一行变灰 {