Hi,
I am using the WPF SortDescriptions sorting technique and I have found that it will not sort numbers. When given a column of numbers to sort it tells me that "Failed to Compare two elements in the array"
Does anyone know how to get around this? Or maybe give me some hints? I noticed that it will only sort strings right, but not numbers. It throws an exception when given a number.
Here is my code thanks
private void SortClick(object sender, RoutedEventArgs e)
{
GridViewColumnHeader column = sender as GridViewColumnHeader;
String field = column.Tag as String;
if (_curSortCol != null)
{
AdornerLayer.GetAdornerLayer(_curSortCol).Remove(_curAdorner);
ListView.Items.SortDescriptions.Clear();
}
ListSortDirection newDir = ListSortDirection.Ascending;
if (_curSortCol == column &&
_curAdorner.Direction == newDir)
newDir = ListSortDirection.Descending;
_curSortCol = column;
_curAdorner = new SortAdorner(_curSortCol, newDir);
AdornerLayer.GetAdornerLayer(
_curSortCol).Add(_curAdorner);
//THIS IS WHERE IT CRASHES!!
ListView.Items.SortDescriptions.Add(
new SortDescription(field, newDir));
}