Hi,
I have a a xamDataPresenter as a grid with only one displayed editable column binded to string value in ObservableCollection. Later the value is saved to database as varchar(255). Sometimes users enter very long string values to the cell and they receive error message from Entity Framework. They would like to have count of characters in the cell displayed on the screen. I understand I cannot use CellUpdated event for this because it happened after user leaves the cell. It looks like CellChanged, DataValueChanged and KeyUp/KeyDown events also don't work. Is it possible to do it in xamDataGrid ?
Thanks,
Ed
Hello Ed,
Thank you for your post!
I have been looking into your issue and have created a small sample application for you. In the application I have a simple XamDataGrid bind to a collection. Then I have created a style for the XamMaskedEditor and in the style for the editor I have created an EventSetter for the ValueChanged event of the XamMaskedEditor.
In the handler of the event I get the length of the NewValue, that the user has typed into the cell and pass it to a TextBlock, that would display it.
In order to get the value of the cell when the user is clicked into the cell (before to start typing) I have handled the EditModeStarted event and get the length of the calls value.
One other this I can suggest regarding the scenario you are trying to achieve is to set the Mask property of the XamMaskedEditor to allow the user to enter only 255 characters in a cell. More about the Mask property of the XamMaskedEditor you can find on the following link from our documentation: http://help.infragistics.com/Help/Doc/WPF/2014.2/CLR4.0/html/xamEditors_Masks.html.
Please find the attached sample application and feel free to let me know if you have any further questions on this matter.
Hi Gergana,
Thank you for your help, everything works fine. However I prefer to set ValueConstraint for XamTextEditor with MaxLength="255" instead of XamMaskedEditor because masked editor doesn't have text wrapping (I'm not sure about this, at least it doesn't have TextWrapping property). Also, "{}{char:n:s}" mask would require to specify all acceptable characters. In my case user can enter any character, not only numbers and letters.