CalendarView Control In Windows 10 Universal App

We have a built in Calendar control from Windows 10 UWP CalendarView, which can provide a standardized way to let users view and interact with a calendar. Selecting multiple dates are also possible through Calendar view.

For creating a new Windows 10 universal project, refer to the following:

Now go to MainPage.XAML and write the below xaml code to show calendar control.
  1. <CalendarView x:Name="myCal"HorizontalAlignment="Center"VerticalAlignment="Center"></CalendarView>  
Next see the properties to set calendar to your wish.

If you want to select multiple date set SelectionMode="Multiple" by default it will be single. Next set the display mode it’s used to display the calendar in different view Month, Year and Decade.

The view looks like the following image.


To get the selected date register event handler for the date control like the following code,
  1. <CalendarView x:Name="myCal"HorizontalAlignment="Center"SelectedDatesChanged="myCal_SelectedDatesChanged"VerticalAlignment="Center"></CalendarView>  
Now go to your code behind page and write the below code to get the selected date. privatevoidmyCal_SelectedDatesChanged(CalendarView sender,
  1. CalendarViewSelectedDatesChangedEventArgsargs)  
  2. {  
  3.     stringselectedDate = args.AddedDates[0].ToString();  
  5. }  
Now run the app and see the output looks like following image.


For more information on Windows 10 UWP, refer to my eBook: 
Please share your comments on this article.
Read more articles on Windows 10:


Up Next
    Ebook Download
    View all
    View all