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
210
XamDateTimeEditor - Default current year when blank
posted

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?

Parents
No Data
Reply
  • 5600
    Offline posted

    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

Children