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
1690
Access cell value during cell editing
posted

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

Parents
  • 22015
    Verified Answer
    posted

    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.

    DataGrid_CharacterCount.zip
Reply Children