Working With The TimePicker Control In Universal Windows App

Prerequisites

  • Visual Studio 2015

Now, let's get started with the following steps:

Step 1 : Create Windows Universal Project

Open Visual Studio 2015 and click File -> New -> Project Option for New Universal App.

Create Windows Universal Project

Step 2: Giving the Project Name

A new project window will open. There, you can select Installed -> Template -> Visual C# -> Windows -> Universal and select a Blank App (Universal Windows).

Type Project Name as TimePickerControl and click the OK button.

Giving the Project Name

Step 3: Setting the platform Versions

Here, we choose the Target Version and Minimum Version for our Universal Windows application. Click OK.

Setting the platform Versions

Step 4: Choose Designer Window

Now, we go to the Solution Explorer and open the MainPage.xaml for design.

Designer Window

Step 5: Designing the App

In the MainPage.xaml designing page, drag the TimePicker control from the tool box. Change the name to mytime in the property window and change the ClockIdentifier property in the 12 hour clock.


Designing the App

Next, add the Textblock from the tool box and change the name in selectedTime.

Designing the App

Step 6: Add the Coding

To add the coding, double click on the TimePicker Control and add the mentioned source code.

Coding

  1. private void mytime_TimeChanged(object sender, TimePickerValueChangedEventArgs e)   
  2. {  
  3.     selectedTime.Text = "Selected time is " + e.NewTime.ToString();  
  4. }  
Step 7: Run the Application

Now, we are ready to run our Project. So, click the Local Machine for running the Application.

Application

Output

Output

Conclusion: I hope you understood TimePicker control in Universal Window and how to run it. 


Similar Articles