WPF Calendar Control holding on to the Mouse(按住鼠标的 WPF 日历控件)
问题描述
因此,我在 VS2010 的全新 WPF 应用程序中删除了 MainWindow.xaml 上的标准 WPF Calendar
控件.如果我单击日历中的某一天,然后尝试单击应用程序的关闭按钮,我必须在关闭按钮上单击两次才能接受单击.就好像 Calendar
没有释放鼠标来与应用程序的其余部分进行交互一样.
So I dropped the standard WPF Calendar
control on the MainWindow.xaml in a brand new WPF App in VS2010. If I click on a day in the calendar and then try to click the Close button for the app, I have to click twice on the close button before it accepts the click. It's acting as if the Calendar
hasn't released the Mouse to interact with the rest of the application.
我已将 Focusable
更改为 false,但效果没有任何变化,我已尝试覆盖 PreviewOnMouseUp
并调用 ReleaseMouseCapture()
无济于事.我对 MouseLeave
和 MouseLeftButtonUp
做了同样的事情,结果相同.鉴于这些事情都不起作用,我怀疑我在叫错树.谷歌没有发现任何值得注意的东西,但也许我的 GoogleFu 今天还达不到标准.
I've changed Focusable
to false, with no change in effect, and I've tried overriding the PreviewOnMouseUp
and calling ReleaseMouseCapture()
to no avail. I've done the same thing with MouseLeave
and MouseLeftButtonUp
with the same result. Given that none of those things are working I suspect I'm barking up the wrong tree. Google has turned up nothing of note, though perhaps my GoogleFu is not up to snuff today.
有什么想法吗?
推荐答案
您可以通过使用如下处理程序订阅日历的 PreviewMouseUp 事件来更改此行为:
You can change this behavior by subscribing to the calendar's PreviewMouseUp event with a handler like this:
private void Calendar_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (Mouse.Captured is CalendarItem)
{
Mouse.Capture(null);
}
}
这篇关于按住鼠标的 WPF 日历控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:按住鼠标的 WPF 日历控件
基础教程推荐
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- c# Math.Sqrt 实现 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01