Introduction:
In prev post i was explained about how to use TimePicker & DatePicker controls in WinRT windows phone 8.1.But the DatePicker is optimized for picking a known date, such as a date of birth, where the context of the calendar is not important. Fortunately from Windows 10 OS(version 10.0.10240.0) Microsoft introduce CalendarView & CalendarDatePicker controls, so these controls can gives you a standardized way to let users view and interact with a calendar.
Requirements:
Description:
This article can explain you about below topics
1. How to create new project in Windows 10?
2. How to use CalendarView control in Windows 10?
3. How to use CalendarDatePicker control in Windows 10?
4. How to run Windows 10 UWP app in emulator?
1. How to create new project in Windows 10?
Before to use calendar controls, first we need to create new project.
2. How to use CalendarView control in Windows 10?
Now its time to use calendar controls and from windows 10 OS we have an in-built class called CalendarView, which can provide a standardized way to let users view and interact with a calendar. If you need to let a user select multiple dates, you must use a CalendarView.
Okay now lets start to use CalendarView in our MainPage.xaml like below:
SelectionMode property is set to Multiple to let a user select multiple dates. DisplayMode property is useful to set calendar startup view and it is having three values(Month,Year,Decade). By default, it starts with the month view open.
So when users click the header in the month view to open the year view, and click the header in the year view to open the decade view. Users pick a year in the decade view to return to the year view, and pick a month in the year view to return to the month view. The two arrows to the side of the header navigate forward or backward by month, by year, or by decade.
And in C# code we can also set selected date, MinDate & MaxDate like below:
Now its time to test our sample, so follow below steps to run the app.
Step 1: In addition to the options to Debug on a desktop device, Visual Studio provides options for deploying and debugging your app on a physical mobile device connected to the computer, or on a mobile device emulator. You can choose among emulators for devices with different memory and display configurations like below
In prev post i was explained about how to use TimePicker & DatePicker controls in WinRT windows phone 8.1.But the DatePicker is optimized for picking a known date, such as a date of birth, where the context of the calendar is not important. Fortunately from Windows 10 OS(version 10.0.10240.0) Microsoft introduce CalendarView & CalendarDatePicker controls, so these controls can gives you a standardized way to let users view and interact with a calendar.
- This article is targeted for windows 10 Universal Windows Platform(Version 1511) , so make sure you’ve downloaded and installed the latest Windows 10 SDK from here.
- We no longer need a developer license with Windows 10. But we must Enable Developer Mode to your device for development.
- This post assumes you’re using Microsoft Visual Studio 2015 or Later.
- This article is developed on windows 8.1 machine. So Visual Studio settings may differ from windows 10 OS VS.
Description:
This article can explain you about below topics
1. How to create new project in Windows 10?
2. How to use CalendarView control in Windows 10?
3. How to use CalendarDatePicker control in Windows 10?
4. How to run Windows 10 UWP app in emulator?
1. How to create new project in Windows 10?
Before to use calendar controls, first we need to create new project.
- Launch Visual Studio 2015
- On the File menu, select New > Project.
- The New Project dialog appears. The left pane of the dialog lets you select the type of templates to display.In the left pane, expand Installed > Templates > Visual C# > Windows, then pick the Universal template group. The dialog's center pane displays a list of project templates for Universal Windows Platform (UWP) apps.
- In the center pane, select the Blank App (Universal Windows) template.The Blank App template creates a minimal UWP app that compiles and runs, but contains no user-interface controls or data. You add controls to the app over the course of this tutorial.In the Name text box, type "UWPCalenderControl".Click OK to create the project.
Visual Studio creates your project and displays it in the Solution Explorer.
2. How to use CalendarView control in Windows 10?
Now its time to use calendar controls and from windows 10 OS we have an in-built class called CalendarView, which can provide a standardized way to let users view and interact with a calendar. If you need to let a user select multiple dates, you must use a CalendarView.
Okay now lets start to use CalendarView in our MainPage.xaml like below:
- <CalendarView x:Name="MyCalendarView DisplayMode="Month" SelectionMode="Multiple" CalendarItemBackground="LightBlue" BorderBrush="Orange" BorderThickness="3"/>
SelectionMode property is set to Multiple to let a user select multiple dates. DisplayMode property is useful to set calendar startup view and it is having three values(Month,Year,Decade). By default, it starts with the month view open.
So when users click the header in the month view to open the year view, and click the header in the year view to open the decade view. Users pick a year in the decade view to return to the year view, and pick a month in the year view to return to the month view. The two arrows to the side of the header navigate forward or backward by month, by year, or by decade.
And in C# code we can also set selected date, MinDate & MaxDate like below:
- MyCalendarView.SelectedDates.Add(new DateTime(2016, 3, 11));// Set selected date is March 3rd 2016);
- MyCalendarView.MinDate = new DateTime(2016, 2, 28);//Min date is FEB 28th 2016
- MyCalendarView.MaxDate = DateTime.Now.AddMonths(3); //Max date is 3 months from current date
- MyCalendarView.NumberOfWeeksInView = 6;//Month view show 6 weeks at a time
3. How to use CalendarDatePicker control in Windows 10?
The CalendarView gives you a standardized way to let users view and interact with a calendar. If you need to let a user select multiple dates, you must use a CalendarView. If you need to let a user pick only a single date and don’t need a calendar to be always visible, consider using a CalendarDatePicker or DatePicker control. So CalendarDatePicker can represents a control that allows a user to pick a date from a calendar display.
Okay now lets start to use CalendarDatePicker in our MainPage.xaml like below:
- <CalendarDatePicker x:Name="MyCalendarDatePicker"/>
But we can also add more below properties to CalendarDatePicker
- customize Header
- PlaceholderText
- We can also set DateFormat
- DisplayMode of calendar(Month, Year, Decade)
- <CalendarDatePicker x:Name="MyCalendarDatePicker" Grid.Row="0" DisplayMode="Month" IsCalendarOpen="True" DateChanged="MyCalendarDatePicker_DateChanged" DateFormat = "{}{dayofweek.full}, {month.full} {day.integer}, {year.full}" PlaceholderText="Choose your date">
- <!--Customising CalendarDatePicker HeaderTemplate -->
- <CalendarDatePicker.HeaderTemplate>
- <DataTemplate>
- <TextBlock FontSize="18" FontWeight="Bold" Foreground="Green">
- <Underline>
- Windows 10 Calendar control
- </Underline>
- </TextBlock>
- </DataTemplate>
- </CalendarDatePicker.HeaderTemplate>
- </CalendarDatePicker>
And in C# code we can also set selected date, MinDate & MaxDate like below:
- MyCalendarDatePicker.Date = new DateTime(2016, 3, 11);//Selected date is March 3rd 2016
- MyCalendarDatePicker.MinDate = new DateTime(2016, 2, 28);//FEB 28th 2016
- MyCalendarDatePicker.MaxDate = DateTime.Now.AddMonths(3);//Max date is 3 months from current date
We can get selected date of calendar view in 'DateChanged' event and in below code I am trying to display selected date in ContentDialog.
- private void MyCalendarDatePicker_DateChanged(CalendarDatePicker sender, CalendarDatePickerDateChangedEventArgs args)
- {
- //Checking selected date is null
- if (args.NewDate != null)
- {
- /* Getting selected new date value*/
- DisplayDate(args.NewDate.Value.ToString());
- }
- }
- private async void DisplayDate(string SelectedDate)
- {
- ContentDialog noWifiDialog = new ContentDialog()
- {
- Title = "Windows 10 Calendar Control",
- Content = "Selected date is: " + SelectedDate,
- PrimaryButtonText = "Ok"
- };
- noWifiDialog.Margin = new Thickness(0, 100, 0, 0);
- await noWifiDialog.ShowAsync();
- }
Now its time to test our sample, so follow below steps to run the app.
Step 1: In addition to the options to Debug on a desktop device, Visual Studio provides options for deploying and debugging your app on a physical mobile device connected to the computer, or on a mobile device emulator. You can choose among emulators for devices with different memory and display configurations like below
Note:
1. It's a good idea to test your app on a deivce with a small screen and limited memory, so use the Emulator 10.0.10240.0 WVGA 4 inch 512MB option.
2. If you want to test our app in physical device, you must Register your Windows Phone device for development.
3. If you already have .APPx file, you can deploy it from WinAppDeployCmd.exe tool
After selecting emulator/device, From the Debug menu, click Start Debugging or Press F5. Then we can found below screen on emulator/device:
Important Notes:
1. A user can clear the selected date by clicking the selected date in the calendar view to deselect it.
2. By default, the minimum date shown in the CalendarView is 100 years prior to the current date, and the maximum date shown is 100 years past the current date. You can change the minimum and maximum dates that the calendar shows by setting the MinDate and MaxDate properties.
3. By default, the month view shows 6 weeks at a time. You can change the number of weeks shown by setting the NumberOfWeeksInView property. The minimum number of weeks to show is 2; the maximum is 8.
2. By default, the minimum date shown in the CalendarView is 100 years prior to the current date, and the maximum date shown is 100 years past the current date. You can change the minimum and maximum dates that the calendar shows by setting the MinDate and MaxDate properties.
3. By default, the month view shows 6 weeks at a time. You can change the number of weeks shown by setting the NumberOfWeeksInView property. The minimum number of weeks to show is 2; the maximum is 8.
4. This sample will be work on all window 10 devices OS devices. And this sample was tested in Emulator & Lumia 735 device with Windows 10 OS (version 1511).
5. Windows 10 SDK works best on the Windows 10 operating system. And it is also supported on: Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2, but not all tools are supported on these operating systems
6. This article is developed on windows 8.1 OS Machine with 64 bit.
Can you change color of the select date from blue to any other colour?
ReplyDeletemaps of usa
ReplyDeleteus map with cities
us maps
usa maps
temperature map usa
maps of us
file
Tomorrow's Future
February 2017 calendar
February calendar 2017
February 2017 calendar printable
February 2017 printable calendar
February 2017 calendar with holiday
February 2017 blank calendar
February 2017 calendar template
file 6
here you get a more interesting game visit my site.
ReplyDeletegames unblocked
unblocked games 77
unblocked games at school
unblocked games 66
October 2017 Calendar
ReplyDeleteOctober Calendar 2017
november 2017 Printable Calendar
ReplyDeletenovember 2017 Calendar Template
Calendar december 2017
apology letter
ReplyDeleteformal letter of apology
apology for damaging borrowed car
apology for something you dont remember