CalendarView Control For Windows 10

CalendarView represents a control that enables a user to select a date by using a visual calendar display. 

Step 1. Open a blank app and add CalendarView and Textblock control either from the toolbox or by copying the following XAML code into your grid.

  1. <TextBlock Text="Calender View" FontSize="20"></TextBlock>  
  2. <StackPanel Margin="0,15,0,0">  
  3.     <CalendarView Name="myCalender" Margin="20,20,0,0" SelectedDatesChanged="myCalender_SelectedDatesChanged" SelectionMode="Multiple" />  
  4.     <TextBlock Name="datesSelected" Foreground="Green" Margin="0,10,0,0"></TextBlock>  
  5. </StackPanel>   
Selection Mode defines whether to select single or multiple dates. 
 
 

Step 2: Copy and paste the following code to the myCalender_SelectedDatesChanged event in the cs page.

  1. var selectedDates = sender.SelectedDates.Select(p => p.Day.ToString() + "/" + p.Month.ToString()).ToArray();  
  2. var multipleDates = string.Join(", ", selectedDates);  
  3. datesSelected.Text = "The selected dayes are " + multipleDates;   

Step 3: Run your application and select a date. The selected dates will be shown in our TextBlock assigned.

  

Up Next
    Ebook Download
    View all
    Learn
    View all