Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1070
Problems Binding DateTime with an XamDateTimeInput
posted

I am trying to use the XamDateTimeInput control for new data entry and for editing existing data. In the first scenario the user enters a new date/time value and in the second scenario existing saved date/time data is displayed to the user so they can modify it if necessary.

I have the following XAML.

<ig:XamDateTimeInput Mask={}yyyy/mm/dd hh:mm:ss” Value=”{Binding DateTimeValue}” … />

I have declared a public notifiable property of type DateTime? called DateTimeValue in my ViewModel. If I set the date part of the XamDateTimeInput, using the dropdown and calendar control, it displays something like 2015/01/21 00:00:00 which should be a valid DateTime object, but the binding to my DateTimeValue property is still set to null. When I check DateTimeValue.HasValue its always FALSE until I have set the hour, minute, AND seconds to something other than 00. If I change the value, using the XamDataTimeInput to something like 2015/01/21 01:02:03 then DateTimeValue.HasValue is true. If the value in the XamDateTimeInput is 2015/01/21 01:00:00 or 2015/01/21 01:02:00 than DateTimeValue.HasValue is false.

I would expect all these values to be valid dates and thus the control should update the DateTimeValue property via the Binding. Am I wrong?

My alternative approach was to not bind to the Value but to the Text property. Now any text that has been entered does successfully get updated in the property, which I called DateTimeText. The problem is setting the value of DateTimeText to a valid string representation of Date is not displayed in the XamDateTimeInput.

If someone could give me some advice as to how to setup a binding so that I can get the DateTime value a user and entered in the XamDateTimeInput control and to be able to perform the opposite which is setting a value in my ViewModel that will be displayed in the control. As it stands now I have to use a combination of the Value and Text properties to accomplish this.

I'm using .NET 4.0 and Infragistics v13.1.

Parents
No Data
Reply
  • 16495
    Offline posted

    Hello Eric,

    Thank you for your post.

    I have been looking into your issue. I researched it and it seems that when you don’t  set your DateTimeValue property to some date and time  and   the user select date using the calendar, he get the message 'Value in the editor is no valid', because there is no time entered and the mask that you had is for date and time. I created a sample application based on your scenario. You can uncomment the line with code in the constructor of view model and see the result.

    Would you please modify my sample or send me an isolated sample application where I can reproduce the issue, in order to be able to research what might be the reason for the behavior?

    Looking forward to hearing from you.

    XamDateTimeInput_Binding.zip
Children