Hi,
If Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern is "dd-MMM-yy" I am getting “Value is invalid” error, when I tried to set the year to 00 using keyboard or using calendar popup (any date in year 2000).
<editors:XamDateTimeEditor Width="200"
FormatProvider="{Binding Source={x:Static thread:Thread.CurrentThread}, Path=CurrentCulture.DateTimeFormat}"
Mask="{}{date} {time}" VerticalAlignment="Bottom"/>
Is it a bug in XamDateTimeEditor ?
Is there is workaround for this situation?
Thanks,
Deep
You will get first chance (i.e. handled) exceptions when the mask is not satisfied. In your case you have a time section in the mask and selecting a date from the dropdown or typing in a date will not automatically fill in the value of the time section. Do these first chance exceptions continue after you have entered in something into the time section of the mask? Or are you saying that you are getting an unhandled exception (i.e. your app is crashing)?
For the Time mask I am handling it (means if the user has not entered any time manually then from code behind I will update time to 12 AM),My problem is with date, when I select any date in year 2000 say 02/02/2000 it is throwing this "Value is invalid" error (but app is not crashing as error is appearing in a message box.) and I can't enter manually a date like 02/02/00.This problem will remain even if I remove {Time} from Mask.
One possible way is to set
InvalidValueBehavior
="RetainValue" or
="RevertValue"
But by doing this I can only suppress the Error message I can't able to set the date to show 02/02/00. Hope you got my problem?
I'm not seeing any messagebox be displayed until the editor leaves edit mode and just selecting an item from the dropdown or typing into the control doesn't do that. Again if you have VS set to break on all exceptions (i.e. you checked Debug->Exceptions...->Common Language Runtime Exceptions) then I would expect that you would get a dialog from VS about the first chance exception. If that is not what you are seeing and you are seeing our messagebox then please provide a sample that demonstrates the problem?
I know the user won't get any error message box until he leaves the edit mode. My question is
If I tried to enter a Date (either through dropdown or through typing) in the year 2000 when my datetime format is "mm/dd/yy" , the XamDateTime editor is not accepting it.The only option left is either change the year to anything other than 2000 or press Esc Key which will revert the Date to previous date.
Now Can you provide a fix or hack (through code or XAML) through which I can set the XamDateTime editor date to say 02/02/00??
If you want to reproduce this issue just use a XamDateTime editor and change the dateTime format using following code before initializing the XamDateTime editor.
culture.DateTimeFormat.ShortDatePattern =
"dd-MM-yy";
culture.DateTimeFormat.LongTimePattern =
"";
and then try to set the date to say 02/02/00 through dropdown or typing.You will find out that there is no way XamDateTimeEditor will accept it.
Hi Andrew,
I got the problem it’s because of the Dll version which I am using. I had tested your code on 2 IG dll
1st on 9.1.20091.1006 in which it works fine but when I used 9.1.20091.2125 (this is the version which we are using in our app) it shows the problem . I tried to attach the DLL of version 9.1.20091.2125 but the site had a restriction to add only 200kb. I hope now you can replicate my problem if you use Dll version 9.1.20091.2125.
Please provide a fix ASAP as this issue is escalated by our client.
I've attached the project I've used to test this and when I use the code you specify with the xamDateTimeEditor (and set the FormatProvider to be the thread's cultureinfo), I do not have a problem typing in 02/02/00 and leaving the control. The only case where there is a problem is if I have your original snippet which has {time} in the mask and the only problem there is that that section needs to have a value in order to be valid (i.e. i have to type in a time). Can you modify this sample to demonstrate the problem you are having?