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 - Prevent right click from selecting row

Thread ID:





123795 Apr 21,2016 10:45 PM UTC May 5,2016 02:44 PM UTC UWP 3
Tags: SfDataGrid
Asked On April 21, 2016 10:45 PM UTC


Is there any way to prevent the right click from changing row selection in a SfDataGrid? I just want to use it for context menus.

Jai Ganesh S [Syncfusion]
Replied On April 22, 2016 05:13 AM UTC

Hi Arvin,

You can prevent the right click from changing row selection in SfDataGrid by wiring the PreviewMouseDown event like below,


void SfdataGrid_PreviewMouseDown(object sender, MouseButtonEventArgs e)




                e.Handled = true;




Jai Ganesh S

Replied On May 4, 2016 11:15 PM UTC

There doesn't seem to be an event called PreviewMouseDown. 

I have a datagrid declared in XAML

<syncfusionGrid:SfDataGrid x:Name="TrackListUi"  ...

in my page's constructor I try to subscribe to the event as you suggested but PreviewMouseDown isn't one of the events in the list. Any suggestions?

Jai Ganesh S [Syncfusion]
Replied On May 5, 2016 02:44 PM UTC

Hi Arvin, 
Sorry for the inconvenience. 
You can prevent the right click from changing row selection in SfDataGrid by customizing the SelectionController and overriding the ProcessPointerPressed like below, 
this.datagrid.SelectionController = new GridSelectionControllerExt(datagrid); 
public class GridSelectionControllerExt : GridSelectionController 
        public GridSelectionControllerExt(SfDataGrid dataGrid) 
            : base(dataGrid) 
        { } 
        protected override void ProcessPointerPressed(PointerRoutedEventArgs args, RowColumnIndex rowColumnIndex) 
            var properties = args.GetCurrentPoint(DataGrid).Properties; 
            if (properties.IsRightButtonPressed) 
                args.Handled = true; 
                base.ProcessPointerPressed(args, rowColumnIndex); 
Jai Ganesh S 


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

This page will automatically be redirected to the 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