title: List Sort Direction is always null for custom sort column in wpf datagrid
body: <p>I have a WPF DataGrid with 3 columns. For the first 2 columns I want the default sorting but for the third one I want a custom sort in ascending/descending order.
  I have handled the sorting event on datagrid as follows:</p>
  
  <pre><code>        private void ReleaseDataGrid_Sorting(object sender, DataGridSortingEventArgs e)
      {
          ListSortDirection direction = (e.Column.SortDirection != ListSortDirection.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending;
          if (e.Column.SortMemberPath == "DisplayName")
          {
              SortStatusImg.Visibility = System.Windows.Visibility.Collapsed;
              SortVersionImg.Visibility = System.Windows.Visibility.Collapsed;
              SortPackageNameImg.Visibility = System.Windows.Visibility.Visible;
              if (direction == ListSortDirection.Ascending)
              {
                  SortPackageNameImg.Source = new BitmapImage(new Uri(@"pack://application:,,,/Resources/sortup.png"));
              }
              else
              {
                  SortPackageNameImg.Source = new BitmapImage(new Uri(@"pack://application:,,,/Resources/sortdown.png"));
              }
          }
          else if (e.Column.SortMemberPath == "UserMachineStatus")
          {
              SortStatusImg.Visibility = System.Windows.Visibility.Visible;
              SortVersionImg.Visibility = System.Windows.Visibility.Collapsed;
              SortPackageNameImg.Visibility = System.Windows.Visibility.Collapsed;
              if (direction == ListSortDirection.Ascending)
              {
                  SortStatusImg.Source = new BitmapImage(new Uri(@"pack://application:,,,/Resources/sortup.png"));
              }
              else
              {
                  SortStatusImg.Source = new BitmapImage(new Uri(@"pack://application:,,,/Resources/sortdown.png"));
              }
          }
          else if (e.Column.SortMemberPath == "ReleaseInfo")
          {
  
              DisplayReleaseList.Sort(new VersionComparerDesc());
  
              SortStatusImg.Visibility = System.Windows.Visibility.Collapsed;
              SortVersionImg.Visibility = System.Windows.Visibility.Visible;
              SortPackageNameImg.Visibility = System.Windows.Visibility.Collapsed;
              if (direction == ListSortDirection.Ascending)
              {
                  SortVersionImg.Source = new BitmapImage(new Uri(@"pack://application:,,,/Resources/sortup.png"));
                  DisplayReleaseList.Sort(new VersionComparer());
              }
              else
              {
                  SortVersionImg.Source = new BitmapImage(new Uri(@"pack://application:,,,/Resources/sortdown.png"));
                  DisplayReleaseList.Sort(new VersionComparerDesc());
              }
  
              RefreshMediaGrid();
              e.Handled = true;
          }
      }
  </code></pre>
  
  <p>For first two columns it works fine. But for the custom sort column, it sorts once in ascending order and later no matter how many times I click on column header it does not sort at all.</p>
  
  <p>When I sort by third column, the ListSortDirection is always null and hence when the control enters this method, direction always is assigned ListSortDirection.Ascending</p>
  
  <p>It does not preserve the sort direction. Please help.</p>