Andrew thank you for your reply! Here is my dilemma:
On my screen I am tracking dirty changes so that I can ask the user at window close whether they want or not to save changes. For I am updating IsDirty on PropertyChanged for my business object binded to the grid.
To solve the issue where the properties are not getting updated unless you lose focus...because there are instances where i can exit the screen and my dirty state is not updated, I added the following. [Note: I found this solution in one of the infragistics posts http://blogs.infragistics.com/forums/t/30136.aspx]
private void xamDataGrid_CellChanged(object sender, Infragistics.Windows.DataPresenter.Events.CellChangedEventArgs e)
{
xamAddFight.ExecuteCommand(DataPresenterCommands.EndEditModeAndAcceptChanges);
xamAddFight.ExecuteCommand(DataPresenterCommands.StartEditMode);
}
Then I added the following to prevent the textbox editor from auto highlighting the first character.
private void xamDataGrid_EditModeStarted(object sender, Infragistics.Windows.DataPresenter.Events.EditModeStartedEventArgs e)
if (e.Editor is XamTextEditor)
(e.Editor as XamTextEditor).SelectionStart = (e.Editor as XamTextEditor).Text.Length;
(e.Editor as XamTextEditor).SelectionLength = 0;
But the problem now is that my text boxes with the reg patterns described in my earlier post is now constantly shooting error messages. Errr.
I found another post where they suggest to edit error messages to use EditModeValidationError so I added the following [Infragistics posts: http://blogs.infragistics.com/wpf/articles/validation-in-the-xamdatagrid.aspx]
private void xamDataGrid_EditModeValidationError(object sender, EditModeValidationErrorEventArgs e)
switch (e.Cell.Field.Name)
case "EndingTime":
e.ErrorMessage = string.Empty;
break;
Now I do not get any messages while typing...the cell does turn red until the entire value is entered correctly...(love this behavior)
The only thing is that when I actually leave the cell I would like the pop up message error in the case the user moved on to another row, edit,etc and the value was not valid.
I have no way of telling my editors when to shoot the proper error message. Is there a better solution for this?
While the IsValueValid would be updated on each keystroke we don't evaluate the InvalidValueBehavior on each - only when it is exiting edit mode or losing focus. Is it possible that you have code that is causing it to exit edit mode or something on each keystroke? If you break into the debugger when you get the error dialog after a keystroke what is in the callstack?
Can someone help me with this?
I'm having a problem when I'm trying to get a pattern to validate for example RegexPattern="(\d{1,2}:\d{2})". When the user is entering the value it validates on every input so they keep getting an error message until they finish entering the entire input.
How do I customize the validate behavior so that the user only gets an error after leaving the control (control looses focus) as opposed to validation on every entry?
For this instance when the user wants to enter 2:10 they get an error when they enter 2, again when they enter : and then again when they enter 1
Hi,
XamTextEditor will validate the input when the user leaves the editor and will take action, like display an error message box, based on its InvalidValueBehavior setting. However it will not restrict the user from typing any characters. BTW, editors expose IsValueValid property that is updated on every character input to reflect whether the current entered value is valid or not. You can for example use that in xaml in a trigger to highlight the editor differently etc... when the value is invalid.
Hope this helps,
Sandip