zoukankan      html  css  js  c++  java
  • WPF ListBoxItem双击、单击事件分别处理

     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         }
  • 相关阅读:
    Python 面向对象补充
    Python 多态
    Web_php_unserialize-攻防世界XCTF
    sqli-labs之Page-4
    sqli-labs之Page-3
    sqli-labs之Page-1
    DVWA-反射型XSS
    DVWA-File Upload
    DVWA-File Inclusion
    DVWA-CSRF
  • 原文地址:https://www.cnblogs.com/Eric-Hwang/p/8487209.html
Copyright © 2011-2022 走看看