MaskedDateTimeInput

4 posts, 1 answers
  1. v00d00
    v00d00 avatar
    5 posts
    Member since:
    Jan 2011

    Posted 18 Mar 2011 Link to this post

    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.
  2. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 21 Mar 2011 Link to this post

    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
  3. DevCraft banner
  4. v00d00
    v00d00 avatar
    5 posts
    Member since:
    Jan 2011

    Posted 21 Mar 2011 Link to this post

    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" />
  5. Answer
    Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 21 Mar 2011 Link to this post

    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
Back to Top