The time picker gives you a standardized way to let users pick a time value using touch, mouse, or keyboard input.
Get the Windows UI Library
Windows UI Library 2.2 or later includes a new template for this control that uses rounded corners. For more info, see Corner radius. WinUI is a NuGet package that contains new controls and UI features for Windows apps. For more info, including installation instructions, see Windows UI Library.
Is this the right control?
Use a time picker to let a user pick a single time value.
For more info about choosing the right control, see the Date and time controls article.
|XAML Controls Gallery|
If you have the XAML Controls Gallery app installed, click here to open the app and see the TimePicker in action.
The entry point displays the chosen time, and when the user selects the entry point, a picker surface expands vertically from the middle for the user to make a selection. The time picker overlays other UI; it doesn't push other UI out of the way.
Create a time picker
This example shows how to create a simple time picker with a header.
<TimePicker x:Name="arrivalTimePicker" Header="Arrival time"/>
TimePicker arrivalTimePicker = new TimePicker(); arrivalTimePicker.Header = "Arrival time";
The resulting time picker looks like this:
For important info about date and time values, see DateTime and Calendar values in the Date and time controls article.
Get the sample code
- XAML Controls Gallery sample - See all the XAML controls in an interactive format.