I have a datagrid that I validate the users input using the following code:
private void MainDataGrid_EditModeValidationError(object sender, EditModeValidationErrorEventArgs e)
{
e.InvalidValueBehavior = InvalidValueBehavior.RetainValue;
e.Handled = true;
}
The issue I'm having is when when the user enters something not valid the XamDialogWindow shows up but it doesn't have focus because of InvalidValueBehavior. Is there a way I can force focus to another control, I know I can use RevertValue however I don't want to revert what the usr types in. When I did research I noticed there's a method in XamDateTimeEditor called InitializeOriginalValueFromValue to help with this issue if I use RevertValue, is there something like that in the DataGrid?
Hello,
Thank you for your post. I have been looking into it and I can say that if the InvalidaValueBehavior is set to RetainValue, you are not allowed to exit edit mode if there is a validation error. Please let me know if you have further questions on this matter.
Looking forward for your reply.
If I change to RevertValue, is there a workaround to keep what the user types in like in a XamDateTimeEditor?
If you set RevertValue the value will revert. Could you please give me more details why do you set a validation, when you want the wrong value to be allowed to be entered?
I set a validation because one column of my grid has a textbox and a button. The user can either enter the a code or click the button to display a XamDialog with a list of codes to choose from. If the user enters manually enters a code in the textbox that is not valid in the list a XamDialog appears saying "this code is not valid please select from the following." What's occuring is when I set the behaviour to RetainValue, when the user enters an invalid code and the XamDialog shows up focus is still set on the cell until the user click on the dialog. Also when the dialog is up the user can type in the cell if they don't click on the dialog box. When I use RevertValue this issue doesn't happen but it reverts the value if the user deletes what's in the cell and clicks away whitout any notification to the user.
So I was wondering if there was a way I could use RevertValue and when the user deletes the value and clicks away somehow retain the new value the user tried to use to trigger the dialog to show up.
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
We decided to take a different approach but thank you.