We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

SfDataGrid InputBindings

Thread ID:





123777 Apr 20,2016 04:02 PM UTC Apr 21,2016 05:58 PM UTC WPF 1
Tags: SfDataGrid
Asked On April 20, 2016 04:02 PM UTC

I am using SfDataGrid in read-only mode.
This grid have context menu to run different commands from ViewModel at selected item (get info, edit, copy and more).
All is OK.
BUT to "Edit" command i have advanced view (another window).
For user expierence i want to add InputBindings ("Enter" and "Mouse Double click") for run "Edit" command.
Nothing works.
Can you help me?
    <KeyBinding Gesture="Enter" Command="{Binding DataGridMouseDoubleClickComm,Source={StaticResource MVViewModel}}" />
    <MouseBinding MouseAction="LeftDoubleClick" Command="{Binding DataGridMouseDoubleClickComm,Source={StaticResource  MVViewModel}}" />
With standart MS DataGrid control this code works perfectly.
P.S. Sorry for my English.

Srinivasan Vasu [Syncfusion]
Replied On April 21, 2016 05:58 PM UTC

Hi Artem,
We have analyzed your query, you can achieve your requirement by creating the custom event triggers instead of InputBindings. You have to create two different custom EventTriggers for MouseDoubleClick and KeyUp event in SfDataGrid. Please refer the below code example and attached sample for more details. 

    //Handle MouseClick

public class EventTriggerExt : System.Windows.Interactivity.EventTrigger


        protected override void OnEvent(EventArgs eventArgs)


            if (this.AssociatedObject is SfDataGrid && eventArgs is MouseButtonEventArgs)


                var args = eventArgs as MouseButtonEventArgs;

                var dataGrid = this.AssociatedObject as SfDataGrid;

                var point = args.GetPosition(dataGrid.GetVisualContainer());


                var rowcolindex = dataGrid.GetVisualContainer().PointToCellRowColumnIndex(point, false);

               if (rowcolindex.IsEmpty)


                var lineinfo = dataGrid.GetVisualContainer().ScrollColumns.GetVisibleLines().GetVisibleLineAtPoint(point.X);

                if (point.X > lineinfo.ClippedCorner)






    //Handle Enter Key

    public class SpaceKeyDownEventTrigger : System.Windows.Interactivity.EventTrigger


        public SpaceKeyDownEventTrigger() : base("KeyUp")



        protected override void OnEvent(EventArgs eventArgs)


            var e = eventArgs as KeyEventArgs;

            if (e != null && e.Key == Key.Enter)





<Syncfusion:SfDataGrid AllowEditing="True" Name="datagrid"                               


                           ItemsSource="{Binding Orders}"

                           SelectedItem="{Binding Selectedvalue}">     


            <local:EventTriggerExt EventName="MouseDoubleClick">

                <i:InvokeCommandAction Command="{Binding DoubleClickCommand}"/>


            <local:SpaceKeyDownEventTrigger EventName="KeyUp">

                <i:InvokeCommandAction Command="{Binding DoubleClickCommand}"/>



Please find the sample from the below location.

Sample Location: http://www.syncfusion.com/downloads/support/forum/123777/ze/SfDataGrid2119996377



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon