Hi. I have folowing scenario in my current project using telerik MaskedDateTimeInput control:
1) I have a ViewModel (Lets call it Employee ViewModel) class with the nullable DateTime property (BirthDate) on it.
2) I have custom user control which exposes DependecnyProperty.
2.1) User control has a MaskedDateTimeInput control which is bound to the dependency property on the control. The Binding is created in the user control constructor and looks like this:
3) I have a view which consumes my custom control. My custom control's dependency property is bound to the exposed public property on the Employee ViewModel using TwoWay Binding
So what is wrong with this whole thing. The Employee View is created before the data is retrived from the server, and there fore first call to the BirthDate getter returns null. Then the data is recieved from the server, NotifyPropertyChanged is called from the setter of the BirthDate Property and I see that the property getter is called second time from the my custom control binding. But data is not displayed inside the MaskedDateTimeInput control. The control will refresh its appearance only after I mouseover it's text area.
Can you provide any feedback on this issue. I have tried a lot of ways to force control redraw but not one worked for me. I personally think that the problem is related to the Watermark (The text which is showed if current value is null) somehow.
1) I have a ViewModel (Lets call it Employee ViewModel) class with the nullable DateTime property (BirthDate) on it.
2) I have custom user control which exposes DependecnyProperty.
public
DateTime? SelectedDate
{
get
{
return
(DateTime?)GetValue(SelectedDateProperty); }
set
{ SetValue(SelectedDateProperty, value); }
}
public
static
readonly
DependencyProperty SelectedDateProperty =
DependencyProperty.Register(
"SelectedDate"
,
typeof
(DateTime?),
typeof
(SlashedDateTimePicker),
new
PropertyMetadata(
null
,UpdaterMethod));
private
static
void
UpdaterMethod(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var control = (SlashedDateTimePicker)d;
//my try to update value
//control.maskedTextBox.GetBindingExpression(RadMaskedDateTimeInput.ValueProperty).UpdateSource();
}
2.1) User control has a MaskedDateTimeInput control which is bound to the dependency property on the control. The Binding is created in the user control constructor and looks like this:
//Inside custom control constructor
var slectedDateBinding =
new
Binding()
{
Source =
this
,
Path =
new
PropertyPath(
"SelectedDate"
),
Mode = BindingMode.TwoWay,
};
maskedDateTimeInput.SetBinding(MaskedDateTimeInputt.ValueProperty, slectedDateBinding);
3) I have a view which consumes my custom control. My custom control's dependency property is bound to the exposed public property on the Employee ViewModel using TwoWay Binding
<
vc:SlashedDateTimePicker
Style
=
"{StaticResource FormInputElement}"
Grid.Column
=
"2"
SelectedDate
=
"{Binding DateOfBirth, Mode=TwoWay}"
/>
So what is wrong with this whole thing. The Employee View is created before the data is retrived from the server, and there fore first call to the BirthDate getter returns null. Then the data is recieved from the server, NotifyPropertyChanged is called from the setter of the BirthDate Property and I see that the property getter is called second time from the my custom control binding. But data is not displayed inside the MaskedDateTimeInput control. The control will refresh its appearance only after I mouseover it's text area.
Can you provide any feedback on this issue. I have tried a lot of ways to force control redraw but not one worked for me. I personally think that the problem is related to the Watermark (The text which is showed if current value is null) somehow.