WPF日历控件抓着鼠标 [英] WPF Calendar Control holding on to the Mouse

查看:88
本文介绍了WPF日历控件抓着鼠标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

于是我在一个品牌在VS2010下降了标准的WPF 日历器上的MainWindow.xaml新的WPF应用程序。如果我点击了一天的日历,然后尝试单击关闭按钮的应用程序,我必须把它接受前点击关闭按钮点击两次。它充当如果日历还没有公布鼠标与应用程序的互动。

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.

我'已经改变了可聚焦为假,在效果没有变化,我已经试过重写 PreviewOnMouseUp 并调用 ReleaseMouseCapture()无济于事。我同样的结果做了同样的事情鼠标离开的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.

任何想法?

推荐答案

日历控件托管在一个弹出,并捕获鼠标。当你点击别的地方第一次,捕捉发送点击弹出窗口,其中,意识到你点击的本身之外,将关闭。点击因此不会去的按钮。

The calendar control is hosted in a popup, and captures the mouse. When you click somewhere else the first time, the capture sends the click to the popup, which, realizing that you've clicked outside of itself, closes. The click therefore does not go to the button.

您可以使用组合框时,看到同样的效果。砸下来,然后点击一个按钮。它不会点击按钮。

You can see the same effect when using a ComboBox. Drop it down, then click on a button. It won't click the button.

不幸的是,这是不可能的,你可以做任何事情来改变这种行为。

Unfortunately, it's unlikely you can do anything to alter this behavior.

修改:最近的.NET版本做一个解决方案成为可能。见二连的回答。

Edit: More recent versions of .NET make a solution possible. See Eren's answer.

这篇关于WPF日历控件抓着鼠标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆