How do I catch the selected date-changed event in the calendar?

I need to start a date selected by the user to do research on the database. The caller class is not a MainWindow class, but an external class called Fixtures, and the object reading GUI calls the producer through a variable. For example, in this case, to access the calendar, run:

MainWindow.AppWindow.Calendar;

      

How do I know if a date has been selected by the user?

+3


source to share


2 answers


If you want to do something when the selected date changes, the calendar control has an event SelectedDatesChanged

. Add an event handler method for this event.

XAML:

<Calendar SelectedDatesChanged="Calendar_OnSelectedDatesChanged"/>

      



Code behind:

private void Calendar_OnSelectedDatesChanged(object sender, SelectionChangedEventArgs e)
{
}

      

It looks like your question might be around object scope in C #. Further explanation required

+3


source


You might want to use DatePicker instead of Calendar and listen for the next SelectedDateChanged event.



You can try and listen for the DisplayDateChanged event for the Calendar class and do something when the date changes.

0


source







All Articles