New to Telerik UI for WPF? Download free 30-day trial

Getting Started

The RadTimePicker is a control that displays a range of times from which the user can select a single time. It essentially inherits RadDateTimePicker and sets the InputMode property to TimePicker.

Assembly References

In order to use the RadTimePicker control in your projects, you have to add references to the following assemblies:

  • Telerik.Windows.Controls
  • Telerik.Windows.Controls.Input

You can find more info here.

Adding Telerik Assemblies Using NuGet

To use RadTimePicker when working with NuGet packages, install the Telerik.Windows.Controls.Input.for.Wpf.Xaml package. The package name may vary slightly based on the Telerik dlls set - Xaml or NoXaml

Read more about NuGet installation in the Installing UI for WPF from NuGet Package article.

Setting the SelectedTime

The SelectedTime property holds the selected time. Examples 1 and 2 demonstrate how you can set this property in xaml and code behind. For more information, check out the Selection article of the RadDateTimePicker.

Example 1: Setting the SelectedTime in xaml

<telerik:RadTimePicker x:Name="timePicker" SelectedTime="15:00" /> 

Example 2: Setting the SelectedTime in code

timePicker.SelectedTime = new TimeSpan(15,0,0); 
timePicker.SelectedTime = New TimeSpan(15,0,0) 

In order to take some action when the SelectedTime is changed, you can handle the SelectionChanged event. You can check out all of the available events in the Events article of the RadDateTimePicker.

StartTime, EndTime and TimeInterval

You can limit the times that can be selected by setting the StartTime and EndTime properties. The TimeInterval property allows user to specify the interval between time slots available for selection. For more information, check out the Clock Items.

Example 2: Setting the StartTime, EndTime and TimeInterval

<telerik:RadTimePicker x:Name="timePicker" TimeInterval="0:30:0" StartTime="0:0:0" EndTime="7:0:0" /> 

Setting the ClockItemsSource

You can also populate the RadTimePicker from code behind by setting its ClockItemsSource property to a collection of TimeSpan objects. Example 3 demonstrates how you can achieve this.

Example 3: Setting the ClockItemsSource

public DataBinding() 
{ 
    this.radTimePicker.ClockItemsSource = this.LoadDataObjects(); 
} 
public ObservableCollection<TimeSpan> LoadDataObjects() 
{ 
    ObservableCollection<TimeSpan> times = new ObservableCollection<TimeSpan>() 
    {  
       new TimeSpan(9,0,0), 
       new TimeSpan(10,0,0), 
       new TimeSpan(10,5,0), 
       new TimeSpan(10,22,0), 
    }; 
    return times; 
} 
Public Sub New() 
    Me.radTimePicker.ClockItemsSource = Me.LoadDataObjects() 
End Sub 
Public Function LoadDataObjects() As ObservableCollection(Of TimeSpan) 
    Dim times As New ObservableCollection(Of TimeSpan)() From { 
        New TimeSpan(9,0,0), 
        New TimeSpan(10,0,0), 
        New TimeSpan(10,5,0), 
        New TimeSpan(10,22,0) 
    } 
    Return times 
End Function 

Setting a Theme

The controls from our suite support different themes. You can see how to apply a theme different than the default one in the Setting a Theme help article.

Changing the theme using implicit styles will affect all controls that have styles defined in the merged resource dictionaries. This is applicable only for the controls in the scope in which the resources are merged.

To change the theme, you can follow the steps below:

  • Choose between the themes and add reference to the corresponding theme assembly (ex: Telerik.Windows.Themes.Windows8.dll). You can see the different themes applied in the Theming examples from our WPF Controls Examples application.

  • Merge the ResourceDictionaries with the namespace required for the controls that you are using from the theme assembly. For the RadTimePicker, you will need to merge the following resources:

    • Telerik.Windows.Controls
    • Telerik.Windows.Controls.Input

Example 4 demonstrates how to merge the ResourceDictionaries so that they are applied globally for the entire application.

Example 4: Merge the ResourceDictionaries

<Application.Resources> 
    <ResourceDictionary> 
        <ResourceDictionary.MergedDictionaries> 
            <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/System.Windows.xaml"/> 
            <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.xaml"/> 
            <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.Input.xaml"/> 
        </ResourceDictionary.MergedDictionaries> 
    </ResourceDictionary> 
</Application.Resources> 

Alternatively, you can use the theme of the control via the StyleManager.

Figure 5 shows a RadTimePicker with the Windows8 theme applied.

Figure 5: RadTimePicker with the Windows8 theme

RadTimePicker with Windows8 theme

Telerik UI for WPF Learning Resources

See also

In this article