WPF Toolkit Calendar takes two clicks to get focus WPF Toolkit Calendar takes two clicks to get focus wpf wpf

WPF Toolkit Calendar takes two clicks to get focus


The calendar can capture the mouse without a date change (e.g. in CalendarMode drill down).A better solution is this:

protected override void OnPreviewMouseUp(MouseButtonEventArgs e){    base.OnPreviewMouseUp(e);    if (Mouse.Captured is CalendarItem)    {        Mouse.Capture(null);    }}


I added this code when changing the SelectedDates of the Calendar and it fixed the issue.

        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