問題描述
因此,我在 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
做了同樣的事情,結果相同.鑒于這些事情都不起作用,我懷疑我在叫錯樹.谷歌沒有發(fā)現任何值得注意的東西,但也許我的 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 日歷控件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!