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.
Unfortunately, activation email could not send to your email. Please try again.

How to detect which header is clicked on

Thread ID:





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

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 06:45 AM

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.

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.