Prerequisites
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.
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.
Step 3: Setting the platform Versions
Here, we choose the Target Version and Minimum Version for our Universal Windows application. Click OK.
Step 4: Choose Designer Window
Now, we go to the Solution Explorer and open the MainPage.xaml for design.
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.
Next, add the Textblock from the tool box and change the name in selectedTime.
Step 6: Add the Coding
To add the coding, double click on the TimePicker Control and add the mentioned source code.
- private void mytime_TimeChanged(object sender, TimePickerValueChangedEventArgs e)
- {
- selectedTime.Text = "Selected time is " + e.NewTime.ToString();
- }
Step 7: Run the Application
Now, we are ready to run our Project. So, click the Local Machine for running the Application.
Output
Conclusion: I hope you understood TimePicker control in Universal Window and how to run it.