So I'm currently using the XamDateTimeEditor and have it working nicely. Most of my datetime properties to which I'm binding are nullable and, for the ones that are not, I'm using a ValueConstraint and the RevertValue behavior to revert to the last valid value when the user clears (or, of course, enters a junk date).
I'm now faced with one final requirement: if the user enters just a month and day, I'd like to default in the current year. What I can't figure out is what event (if any) will let me intercept and modify the value before the InvalidBehavior has a chance to revert it. By the time Validation or ValidationError events kick in, it's already flipped the value back to what it was before I messed up the value.
Is there such an event where I can insert my logic?
Hello,
I can suggest you to hook up to EditModeEnding event and put your logic there:
Regex regex = new Regex(@"\d{1,31}/\d{1,12}/");
if (regex.IsMatch(xamDateTimeEditor1.Text))
{
if (xamDateTimeEditor1.Mask == "dd/mm/yyyy")
xamDateTimeEditor1.Text += DateTime.Now.Year;
}
Hope this helps you.
Regards,
Anastas
Thanks, but that doesn't help me. I don't want to default to today's date if the whole thing is blank. I want to default in the year portion if it's blank (i.e. they enter a month and day and then tab out of the field).
Good news is we got it figured out. Turns out, there's a property for that: AutoFillDate. We just set that to AutoFillDate.Year and it works like a charm.
Thanks anyway!