Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a DataGrid in my project where I am hiding the column headers. When user clicks on a button, I want to sort grid based on first column.
But when I dont hide mu column header and click on it, it sorts column. Please help.

What I have tried:

I tried following code which is not working

public MainWindow()
{
InitializeComponent();
dataGrid1.Loaded += (s, e) =>
{
dataGrid1.Sorting -= DataGrid1_Sorting;
dataGrid1.Sorting += DataGrid1_Sorting;
};
}

private void DataGrid1_Sorting(object sender, DataGridSortingEventArgs e)
{
}

private void Button_Click(object sender, RoutedEventArgs e)
{
DataGrid1_Sorting(dataGrid1, new DataGridSortingEventArgs(dataGrid1.Columns[0]));
}
Posted
Updated 4-Aug-17 12:06pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900