This is a migrated thread and some comments may be shown as answers.

I think I found a nasty bug

1 Answer 70 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
Randy Hompesch
Top achievements
Rank 1
Randy Hompesch asked on 09 Feb 2017, 11:27 AM

So, I have a RadDock setup. In the hosting main window there is a radmenu followed by a  radtoolbar where I have a toolbarbutton for saving. Below that I have a raddocking that has a pane that hosts my usercontrol that contains, among other things a the RadDateTimePicker shown below. It works great except in one odd condition. If the txtClosedDate has a valid value and the user blanks it out and then hit's the button in the toolbar without clicking or tabbing to another field, the null value is not bound back to the source and my viewmodel receives the original date value instead of null. If, however, the user goes to any other field on the user control, thereby forcing a lost focus event the correct binding happens. I have hacked around the problem with the following code, but I think you boys need to fix this on your side.

Thanks ... Ed

 

// this is a awful hack to work around a bug where, when the raddatetimepicker's text is cleared and the
// user clicks on the save button in the toolbar (which is outside the usercontrol), the bound value does not get updated properly.
// it works fine when going from an empty state to a valid date, just not the other way around.
private void txtClosedDate_KeyUp(object sender, KeyEventArgs e)
{
    if (string.IsNullOrWhiteSpace(this.txtClosedDate.CurrentDateTimeText ))
    {
        this.txtClosedDate.SelectedValue = null;
        var binding = this.txtClosedDate.GetBindingExpression(RadDateTimePicker.SelectedValueProperty);
        binding.UpdateSource();
    }
}

 

<telerik:RadDateTimePicker x:Name="txtClosedDate" Width="175" Grid.Row="2" Grid.Column="3"
      HorizontalAlignment="Left"     CalendarStyle="{StaticResource calendarStyle}"
          InputMode="DatePicker" SelectedValue="{Binding Request.ClosedDate, Mode=TwoWay,
     UpdateSourceTrigger=PropertyChanged }"
           KeyUp="txtClosedDate_KeyUp"
/>

 

NOTE THAT THIS STYLE IS AT THE APP RESOURSE LEVEL. I Doubt it has anything to do with the problem.

<Style x:Key="calendarStyle" TargetType="telerik:RadCalendar" BasedOn="{StaticResource RadCalendarStyle}">         <Setter Property="AreWeekNumbersVisible" Value="False" ></Setter>     </Style>

1 Answer, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 13 Feb 2017, 11:51 AM
Hello Randy,

Thanks for contacting us.

Could you please try to isolate the issue in a really sample project, so we can investigate it on our side? You could open up a support ticket where you would be able to attach an archive with the project.

I'm looking forward to hearing from you.

Regards,
Kalin
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
DateTimePicker
Asked by
Randy Hompesch
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Share this question
or