How to select date using right click operation in WPF Calendar?
In WPF Calendar, you can select the date using right click operation through MouseRightButtonDown and PreviewMouseMove events as per the following code example.
XAML
<syncfusion:CalendarEdit PreviewMouseMove="CalendarEdit_PreviewMouseMove" MouseRightButtonDown="CalendarEdit_MouseRightButtonDown"> </syncfusion:CalendarEdit>
C#
// Occurs When the Mouse Right Button is clicked private void CalendarEdit_MouseRightButtonDown(object sender, MouseButtonEventArgs e) { if((!(Keyboard.IsKeyDown(Key.LeftCtrl)))&&(!(Keyboard.IsKeyDown(Key.RightCtrl)))) (sender as CalendarEdit).SelectedDates.Clear(); DayCell s = e.Source as DayCell; if (s != null) { (sender as CalendarEdit).Date = s.Date.ToDateTime((sender as CalendarEdit).Calendar); (sender as CalendarEdit).SelectedDates.Add((sender as CalendarEdit).Date); } } // Occurs When the cursor moves to the selected area private void CalendarEdit_PreviewMouseMove(object sender, MouseEventArgs e) { if (e.MouseDevice.RightButton == MouseButtonState.Pressed) { DayCell s = e.Source as DayCell; if (s != null) { (sender as CalendarEdit).SelectedDates.Add(s.Date.ToDateTime((sender as CalendarEdit).Calendar)); } } }
The following screenshot displays the date selection using right click in CalendarEdit.
Figure 1: Date selection using right click in CalendarEdit
Conclusion
I hope you enjoyed how to select Date using right click operation in WPF Calendar.
You can refer to our WPF Calendar feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WPF Calendar example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!