码迷,mamicode.com
首页 > Windows程序 > 详细

WPF ListBoxItem双击、单击事件分别处理

时间:2018-03-01 11:42:48      阅读:1243      评论:0      收藏:0      [点我收藏+]

标签:start   tar   hand   nbsp   down   eve   invoke   eset   double   

 1      private void listBox_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 2         {            
 3             var element = (FrameworkElement)sender;
 4             if (e.ClickCount == 1)
 5             {
 6                 var timer = new System.Timers.Timer(500);
 7                 timer.AutoReset = false;
 8                 timer.Elapsed += new ElapsedEventHandler((o, ex) => element.Dispatcher.Invoke(new Action(() =>
 9                 {
10                     var timer2 = (System.Timers.Timer)element.Tag;
11                     timer2.Stop();
12                     timer2.Dispose();
13                     UIElement_Click(element, e);
14                 })));
15                 timer.Start();
16                 element.Tag = timer;
17             }
18             if (e.ClickCount > 1)
19             {
20                 var timer = element.Tag as System.Timers.Timer;
21                 if (timer != null)
22                 {
23                     timer.Stop();
24                     timer.Dispose();
25                     UIElement_DoubleClick(sender, e);
26                 }
27             }
28         }
29 
30         private void UIElement_Click(object sender, MouseButtonEventArgs e)
31         {
32             
33         }
34 
35         private void UIElement_DoubleClick(object sender, MouseButtonEventArgs e)
36         {
37             
38         }

 

WPF ListBoxItem双击、单击事件分别处理

标签:start   tar   hand   nbsp   down   eve   invoke   eset   double   

原文地址:https://www.cnblogs.com/Eric-Hwang/p/8487209.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!