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
110
Xamdatagrid set dynamic fields entering in edit mode on double click
posted

Hello,

How can I define a dynamic field to enter in edit mode only on double click?

Thanks.

  • 1560
    Offline posted
    Hello,

    I have been looking into your requirement and created a small sample in order to demonstrate how such behavior could be achieved. For the dynamic field creation, I used the example in this topic in our documentation.

    In order to enter edit mode only on double click, I defined a global variable initially set to false, and depending on its value I canceled the XamDataGrid's EditModeStarting event.

    In the XamDataGrid's PreviewMouseDoubleClick event handler, I changed the variable value to true and execute the StartEditMode command that would invoke the EditModeStarting event for the active cell.

    bool isDoubleClicked = false;
         private void XamDataGrid1_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
            {           
                    isDoubleClicked = true;
                    xamDataGrid1.ExecuteCommand(DataPresenterCommands.StartEditMode);                   
               
            }
            private void XamDataGrid1_EditModeStarting(object sender, Infragistics.Windows.DataPresenter.Events.EditModeStartingEventArgs e)
            {
                if (!isDoubleClicked)
                {
                    e.Cancel = true;
                }
                isDoubleClicked = false;
            }

    Attached you will find my sample for your reference. Please test it on your side and let me know how it behaves. If this is not an accurate demonstration of what you are trying to achieve please feel free to modify it and send it back to me along with steps to reproduce. Alternatively, if the behavior cannot be replicated please feel free to provide your own sample. Remove any external dependencies and code that is not directly related to the issue, zip your application, and attach it in this case.

    Having a working sample on my side, which I can debug, is going to be very helpful in finding the root cause of this behavior.

    Thank you for your cooperation.

    Looking forward to hearing from you.

    Sincerely,
    Teodosia Hristodorova
    Associate Software Developer