DataBinding to SelectedTime

2 posts, 0 answers
  1. Sam
    Sam avatar
    19 posts
    Member since:
    May 2009

    Posted 27 Jul 2010 Link to this post

    Hi There,

    I simply bind the SelectedTime to a TimeSpan? property in the ViewModel.  The problem I am having is that when the TimeSpan? is set to null, the TimePicker control still displays the previous non null value.

    To get the behavior to work, first click 'Set Time Picker to 5am' then 'Set Time Picker To Null'.

    I am using 'Telerik.Windows.Controls.Input' version '2010.2.714.1040'

    Please advice if this is the correct way to bind to the TimePicker?


    public class MainPageViewModel : INotifyPropertyChanged {
        private TimeSpan? _selectedTime;
        public MainPageViewModel() {
            SetTimePickerCommand = new DelegateCommand(( o ) => {
                SelectedTime = new TimeSpan(5, 0, 0);
            }, ( o ) => {
                return true;
            SetTimePickerToNullCommand = new DelegateCommand(( o ) => {
                SelectedTime = null;
            }, ( o ) => {
                return true;
        public ICommand SetTimePickerToNullCommand { get; private set; }
        public ICommand SetTimePickerCommand { get; private set; }
        public TimeSpan? SelectedTime {
            get { return _selectedTime; }
            set {
                if (_selectedTime == value) {
                _selectedTime = value;
        #region INotifyPropertyChanged Members
        public event PropertyChangedEventHandler PropertyChanged;
        private void OnPropertyChanged( string propertyName ) {
            if (PropertyChanged == null) {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));

        <local:MainPageViewModel x:Key="ViewModel" />
        <Binding Source="{StaticResource ViewModel}" />
        <telerikInput:RadTimePicker Grid.Row="0"
                                    SelectedTime="{Binding SelectedTime}" />
        <Button Command="{Binding SetTimePickerToNullCommand}"
                Content="Set Time Picker To Null" />
        <Button Command="{Binding SetTimePickerCommand}"
                Content="Set Time Picker To 5 AM" />


  2. George
    George avatar
    1332 posts

    Posted 29 Jul 2010 Link to this post

    Hello Sam,

    Thank you for contacting us.

    Thank you for reporting this bug, it helps us in improving our products. I am glad to give you points for reporting this abnormal behavior of our RadTimePicker control. We will fix this bug in one of our future releases. You can track this progress in our Public Issue Tracking System (PITS) with Issue ID = 2902.

    Please do not hesitate to contact us if you require any further information.

    Best wishes,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
Back to Top