Articles in this section
Category / Section

How to select date using right click operation in WPF Calendar?

2 mins read

In WPF Calendar, you can select the date using right click operation through MouseRightButtonDown and PreviewMouseMove events as per the following code example.


<syncfusion:CalendarEdit  PreviewMouseMove="CalendarEdit_PreviewMouseMove" MouseRightButtonDown="CalendarEdit_MouseRightButtonDown">


// 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


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 forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment