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
755
InvalidValueBehavior="DisplayErrorMessage" : How to control the text displayed in the EditModeValidationError event?
posted

Hi,

I'm using a XamDateTimeEditor and I specified a ValueConstraint in the xaml.  I also specified InvalidValueBehavior="DisplayErrorMessage".

I dont want to show the default message.  I want to control the message depending on the value specified.  If it's over or lower...  In the EditModeValidationError event, I only have acces to the original value.  I dont see the new value.  I tried to set the message to e.ErrorMessage = "";

and use the CellUpdated event to check the value, but its not called until the ValueConstraint is respected.

How can I access the old and new valeur of the cell to control the message displayed?  Or is there a way to set the InvalidValueBehavior to none?

Parents
  • 54937
    Suggested Answer
    Offline posted

    girardkarine said:
    I dont want to show the default message.  I want to control the message depending on the value specified.  If it's over or lower...  In the EditModeValidationError event, I only have acces to the original value.  I dont see the new value. 

    Well if the value could be parsed then the Value property of the editor should be the current value. If the error occurred because the value could not be parsed then you might have to look at the Text property in the EditModeValidationError event and then set the e.ErrorMessage accordingly. Note I believe in 9.2 and later the error message when you have set the constraints will be more descriptive so if for example you had set the MaxExclusive to 150 and you entered 150 as the value in 9.1 the error message would have been something like "Value is invalid." but in 9.2 it will be something like "Value must be lessage than 150".

    girardkarine said:
    Or is there a way to set the InvalidValueBehavior to none?

    There isn't a none because the editor must do something - revert to the old value or keep the invalid value and stay in edit mode but it can't leave edit mode in the invalid state.

Reply Children