Hi,
I'm required to show the following format througt the application "yyyy-MMM-dd". I define the thread as follow
var cultureInfo = System.Globalization.CultureInfo.CreateSpecificCulture(""); var dateTimeFormatInfo = new DateTimeFormatInfo(); dateTimeFormatInfo.ShortDatePattern = "yyyy-MMM-dd"; dateTimeFormatInfo.DateSeparator = "-"; cultureInfo.DateTimeFormat = dateTimeFormatInfo; System.Threading.Thread.CurrentThread.CurrentCulture = cultureInfo;
Everything works fine however the when I go to edit mode the format goes to "yyyy-MM-dd" and I have no idea where that come from.
Regards,
Dominik
The masked editor (xamDateTimeEditor is a derived xamMaskedEditor) does not currently support Month/Day name sections - only the numeric value - so that is why the mask is using "MM" when you go into edit mode.
Ok, but how can I change that behavior, any solution is acceptable. Is it possible to inherit from XamDateTimeEditor and override something.
I don't really have a way around this. The xamDateTimeEditor is based upon using a specified mask and it does the parsing/validation based on that mask. You might be able to re-template the xamDateTimeEditor to have a TextBox that is bound to the Value property and use your own ValueConverter to handle converting between the DateTime (or null) from the Value and the string needed for the textbox but that will circumvent the masking and I don't think you'll be able to do anything in terms of validating the value.
The control uses the mask that it is provided (or one that is inferred based on the datatype) to determine what characters are accepted and also uses that to parse the characters entered. The full list of supported mask characters is documented in the help here. It does not support everything that a format string could accept and in the case of datetime it does not support named Month or Day sections. It only supports numerical input for the month number and day number for the entry of the value which is why the "MMM" was translated into the mask section "mm". The control will use the Format when the control is not in edit mode to display the value. The ability to support named Day/Month sections will be submitted as a feature request.
Hi Andrew,
Thanks for you're answer.
Sorry I'm confuse you wrote "based upon using a specified mask and it does the parsing/validation based on that mask", so it suppose I can you any mask that I want since it's specified. So how can I specify "yyyy-MMM-dd"
I really need this to get done, and the behavior should be the same (validation, spin, ...). We naturally expected that a date time control allow the format to be changed.