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.