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

How to detect which header is clicked on

Thread ID:





127671 Dec 1,2016 04:38 PM UTC Dec 2,2016 11:45 AM UTC UWP 1
Tags: SfDataGrid
David Harvey
Asked On December 1, 2016 04:38 PM UTC

I wish to add context sensitive menu to a right click event on a header, and therefore need to know which column header was clicked on.

In other words: Right clicking on a header should result in executing code that includes some information somewhere on which column header was clicked on.

Is this possible?

Thank you.

Jai Ganesh S [Syncfusion]
Replied On December 2, 2016 11:45 AM UTC

Hi David, 
You can achieve your requirement for adding the context menu in column header and will get the details of the column header like below, 
                    <MenuFlyoutItem Text="Sort Ascending" Command="{Binding Path=DataContext.SortAscendingCommand}" CommandParameter="{Binding}" /> 
private DelegateCommand _sortAscendingCommand; 
public DelegateCommand SortAscendingCommand 
        if (_sortAscendingCommand == null) 
            _sortAscendingCommand = new DelegateCommand(CanSortAscending, SortAscending); 
        return _sortAscendingCommand; 
    set { _sortAscendingCommand = value; } 
private void SortAscending(object param) 
    if (param is GridColumnContextMenuInfo) 
        var grid = (param as GridContextMenuInfo).DataGrid; 
        var column = (param as GridColumnContextMenuInfo).Column; 
        grid.SortColumnDescriptions.Add(new SortColumnDescription() { ColumnName = column.MappingName, SortDirection = ListSortDirection.Ascending }); 
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