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.
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]));
- }
Vipan SharmaPosted Aug 5, 2017, 1:35 AM
Midhun TpPosted Aug 5, 2017, 1:00 AM