WPF Calendar Control holding on to the Mouse

后端 未结 4 798
孤独总比滥情好
孤独总比滥情好 2021-01-11 14:20

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 cli

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-11 15:01

    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);
        }
    }
    

提交回复
热议问题