tim*_*ath 29 .net wpf calendar wpftoolkit
我正在使用作为WPF工具包一部分的WPF日历.
我在控件上有两个不同的日历.当我尝试从一个日历然后从第二个日历中选择日期时,我必须两次点击第二个日历以使其选择日期.
有没有其他人有这个问题并知道解决方案?
Mar*_*tin 35
日历可以捕获鼠标而无需更改日期(例如,在CalendarMode向下钻取).更好的解决方案是:
protected override void OnPreviewMouseUp(MouseButtonEventArgs e)
{
base.OnPreviewMouseUp(e);
if (Mouse.Captured is CalendarItem)
{
Mouse.Capture(null);
}
}
Run Code Online (Sandbox Code Playgroud)
我在更改日历的 SelectedDates 时添加了此代码,它解决了问题。
Private Sub Calendar_SelectedDatesChanged(ByVal sender As Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs) Handles Me.SelectedDatesChanged
Me.DisplayDate = CType(Me.SelectedDate, DateTime)
' This is to prevent the Calendar DayButtons from holding the focus in the Calendar.
Me.CaptureMouse()
Me.ReleaseMouseCapture()
End Sub
Run Code Online (Sandbox Code Playgroud)