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

MaskedDateTimeInput

3 Answers 151 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
v00d00
Top achievements
Rank 1
v00d00 asked on 18 Mar 2011, 11:06 PM
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. 
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.

3 Answers, 1 is accepted

Sort by
0
Alex Fidanov
Telerik team
answered on 21 Mar 2011, 09:30 AM
Hello v00d00,

Which build are you using to test this? I have tried with the release version (2011.1.217.1040) and this worked correctly. If you are using the same build, is it possible to provide more details on your setup so that we can test this again.

Kind regards,
Alex Fidanov
the Telerik team
0
v00d00
Top achievements
Rank 1
answered on 21 Mar 2011, 10:24 AM
The version of the Telerik.Windows.Controls.Input dll is 2011.1.315.1040 actually.

This may be important. This is how InputControl is defined in XAML
<Controls:RadMaskedDateTimeInput x:Name="maskedTextBox"
 Grid.Column="0"
 HorizontalAlignment="Stretch"
 Mask="dd/MM/yyyy"
 Placeholder=" "
 EmptyContent="Empty"
 IsClearButtonVisible="False" />
0
Accepted
Alex Fidanov
Telerik team
answered on 21 Mar 2011, 05:15 PM
Hi v00d00,

I managed to reproduce this issue. The NotFocused visual state was not being updated correctly. This will be resolved with the next internal build. I have also updated your Telerik points accordingly.

Best wishes,
Alex Fidanov
the Telerik team
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
v00d00
Top achievements
Rank 1
Answers by
Alex Fidanov
Telerik team
v00d00
Top achievements
Rank 1
Share this question
or