We have WPF application, In which we are ListView in One form, We want to order item alphanumerically.
When we sort the columns it needs to sort alpha numerical EG
AW1 AW2 AW3
At the moment it is sorting
AW1 AW100 AW2 AW200
So what need to be changed?
if (lastDirection == ListSortDirection.Ascending)
{
direction = ListSortDirection.Descending;
}
else
{
direction = ListSortDirection.Ascending;
}
And
// get the sort property name from the column's information.
string sortPropertyName = sortableGridViewColumn.SortPropertyName;
// Sort the data.
Sort(sortPropertyName, direction);
SORT function like this,
private void Sort(string sortBy, ListSortDirection direction)
{
lastDirection = direction;
ICollectionView dataView = CollectionViewSource.GetDefaultView(this.ItemsSource);
dataView.SortDescriptions.Clear();
SortDescription sd = new SortDescription(sortBy, direction);
dataView.SortDescriptions.Add(sd);
dataView.Refresh();
}