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
535
Exit edit mode when mouse clicked anywhere on UI
posted

Hi,

I am developing an application in WPF where I am using Xamdatagrid. 

There are multiple containers which are docked to the window and few on them contain the grid. My requirement is that when my grid is in edit mode and I click anywhere in the application I want the edit mode to end. I've tried LostFocus and all sorts of things but this doesn't seems to work.

Kindly help

  • 3520
    Offline posted

    Hello neelesh,

    If I understood correctly you need to end edit mode when clicking anywhere out of the ContentPane holding the XamDataGrid. If this is the case what I can suggest is handling the LostKeyboardFocus event of the in-cells value editors and call the EndEditMode() method:
    private void Editor_LostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
            {
                (sender as ValueEditor).EndEditMode(true, true);
            }

    This approach is implemented in the sample application I am attaching for your reference. I would also recommend referring to the following thread where Andrew discusses different options and potential issues when it comes to focus in WPF:

    http://es.infragistics.com/community/forums/t/35805.aspx

    GridInputBindingInDock.zip