当前位置:网站首页>Solution to control double click conflict in WPF
Solution to control double click conflict in WPF
2022-06-10 05:02:00 【Shunnet】
When you are setting a button to click and double-click [ Normally there are two events ]
After the event is created , Clicking the control is normal , Go to click event
When double-click , You'll find that , It will first click on the event , Then enter the double click event , It's a headache
【 On the talent , Flower hands shake up 】
Shake tired , Take a look at the code 【 An event is settled 】
/// <summary>
/// Number of hits
/// </summary>
int CkickCount = 0;
/// <summary>
/// Double click
/// </summary>
bool IsDoubleClick = false;
/// <summary>
/// When the mouse presses
/// </summary>
private void Button_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
++ChannelCkickCount;
DispatcherTimer ClickTimer = new DispatcherTimer();
ClickTimer.Interval = new TimeSpan(0, 0, 0, 0, 200);
ClickTimer.Tick += (s, e1) =>
{
ClickTimer.IsEnabled = false;
ChannelCkickCount = 0;
if (!ChannelIsDoubleClick) { ClickCommand(); }
ChannelIsDoubleClick = false;
};
ClickTimer.IsEnabled = true;
if (ChannelCkickCount % 2 == 0)
{
ClickTimer.IsEnabled = false;
ChannelCkickCount = 0;
ChannelIsDoubleClick = true;
DoubleClickCommand();
}
}
/// <summary>
/// single click
/// </summary>
private void ClickCommand()
{
}
/// <summary>
/// double-click
/// </summary>
private void DoubleClickCommand()
{
}Copy
Realization
// Normal operation
The object of the button .PreviewMouseLeftButtonDown +=Button_PreviewMouseLeftButtonDown;
// Operation with parameters 【 The event method also has to define parameters 】
The object of the button .PreviewMouseLeftButtonDown += delegate (object sender, MouseButtonEventArgs e) {Button_PreviewMouseLeftButtonDown(sender, e, 【 Here are the passed parameters 】); };Copy
Get it done , Point like collection and pay attention to
“ Focus on [ Downstream network ] WeChat official account , Learn more and more interesting real-time information ”
The author of this article :[ Blogger ] dashun
Link to this article :https://shunnet.top/BJ36bi
Copyright notice : Reprint with reference to , thank you
边栏推荐
- Proteus simulation stm32f103r6tx - external interrupt control LED on and off (cube mx+keil5+proteus)
- 信息学奥赛一本通 1279:【例9.23】橱窗布置(flower) | 洛谷 P1854 花店橱窗布置
- .NET C#基础(7):接口 - 人如何和猫互动
- photoClip.js手机图片上传截取插件
- 2022.5.25-----leetcode. four hundred and sixty-seven
- Mindspire's nn Can pad specify dimension filling
- Apispace sunrise sunset API interface is free and easy to use
- 2022 examination questions and online simulation examination for main principals of hazardous chemical business units
- 2022年危险化学品生产单位安全生产管理人员操作证考试题库及答案
- Why is mindspore 1.5rcgraph mode slow to train?
猜你喜欢

2022制冷与空调设备运行操作特种作业证考试题库模拟考试平台操作
![[UE4 automatic terrain material]](/img/59/34cf7b85d66cdc608e3a3626c61239.png)
[UE4 automatic terrain material]

Yuandao communication has passed the registration: its annual revenue is 1.625 billion yuan, and its performance is highly dependent on China Mobile

元道通信通过注册:年营收16.25亿 业绩高度依赖中移动
![[general database tools] Shanghai daoning provides developers, analysts and database administrators with a tool for all databases and operating systems - dbvisualizer](/img/ce/4d531860a00381f26e09fbf5bc5916.png)
[general database tools] Shanghai daoning provides developers, analysts and database administrators with a tool for all databases and operating systems - dbvisualizer

2022年危险化学品生产单位安全生产管理人员操作证考试题库及答案

Contact QR code generation plug-in qrcode js

2022年流动式起重机司机考试题及在线模拟考试

大事件回顾 | Eolink 5月重要动态速览!

2022山东省安全员C证考试题库及答案
随机推荐
2022g1 industrial boiler stoker examination questions and answers
使用MindSpore在GPU-PYNATIVE/ CPU-GRAPH_MODE 与 GPU-GRAPH_MODE 执行不一致
Installing mindinsight in the mindspire official website container does not work locally
Mindspire's nn Can pad specify dimension filling
mindspore训练阶段报错:Not find op[Add] in akg
TCP (sliding window, flow control)
Mindspire [dataset function] cannot view datasets
Informatics Olympiad 1288: Triangle optimal path problem | openjudge noi 2.6 7625: triangle optimal path problem
得物登录组件重构
Tips for speeding up kettle insertion
Some beautiful JS prompt boxes
【创新文档技术解决方案】上海道宁为您提供涵盖整个文档起草生命周期的产品——Litera,帮助用户创建质量更高的文档
Process, time slice, concurrency and parallelism
Apispace sunrise sunset API interface is free and easy to use
信息学奥赛一本通 1287:最低通行费 | OpenJudge NOI 2.6 7614:最低通行费
24. 浏览器对象模型 BOM
自定义Tooltips提示气泡Js插件
Proteus仿真stm32f103R6Tx——外部中断控制LED亮灭(Cube MX+Keil5+proteus)
js微信小游戏之打蚊子
微信手机端js小游戏踩方块源码