From 146f597a0bf419c2e2e8dfca6bc7f49da271813f Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Wed, 1 Feb 2023 15:23:17 +0800 Subject: [PATCH] Fix the problem after clicking to sort and drag --- v2rayN/v2rayN/Views/MainWindow.xaml.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml.cs b/v2rayN/v2rayN/Views/MainWindow.xaml.cs index 1ba77762..a6dc9db2 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/MainWindow.xaml.cs @@ -254,11 +254,19 @@ namespace v2rayN.Views private void LstProfiles_ColumnHeader_Click(object sender, RoutedEventArgs e) { var colHeader = sender as DataGridColumnHeader; - if (colHeader == null || colHeader.TabIndex < 0) + if (colHeader == null || colHeader.TabIndex < 0 || colHeader.Column == null) { return; } - if (colHeader.TabIndex == 0) + + //find index + var index = lstProfiles.Columns.IndexOf(colHeader.Column); + if (index < 0) + { + index = colHeader.TabIndex; + } + + if (index == 0) { foreach (var it in lstProfiles.Columns) { @@ -268,7 +276,7 @@ namespace v2rayN.Views return; } - ViewModel?.SortServer(colHeader.TabIndex); + ViewModel?.SortServer(index); } private void menuSelectAll_Click(object sender, RoutedEventArgs e)