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 日历控件
基础教程推荐
- C# 从 List<List<int>> 中删除重 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- WPF 模态进度窗口 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
