I have a ListView where I am trying to sort by three columns: NumRejected, DueDate, Number. I have three sort descriptors:
MyListView.SortDescriptors.Add(
new PropertySortDescriptor
{
PropertyName = "NumRejected",
SortOrder = SortOrder.Descending
}
);
MyListView.SortDescriptors.Add(
new PropertySortDescriptor
{
PropertyName = "DueDate",
SortOrder = SortOrder.Ascending
}
);
MyListView.SortDescriptors.Add(
new PropertySortDescriptor
{
PropertyName = "Number",
SortOrder = SortOrder.Ascending
}
);
This works until there is a null value for DueDate. What I'm trying to do is: if there is a null for DueDate don't apply that SortDescriptor, just move on to the next. So for example I have three results in the ListView with values in all columns, they get sorted by NumRejected first, then DueDate then Number. If I also have some results with no DueDate I want them to be sorted NumRejected then Number, ignoring the DueDate. These should be below the three with DueDates.
At the moment a null on DueDate is being treated as the lowest value for that column, so they are at the top of the list.
I think a DelegateSortDescriptor might be the way to go, but I can't find any examples how to use that.
MyListView.SortDescriptors.Add(
new PropertySortDescriptor
{
PropertyName = "NumRejected",
SortOrder = SortOrder.Descending
}
);
MyListView.SortDescriptors.Add(
new PropertySortDescriptor
{
PropertyName = "DueDate",
SortOrder = SortOrder.Ascending
}
);
MyListView.SortDescriptors.Add(
new PropertySortDescriptor
{
PropertyName = "Number",
SortOrder = SortOrder.Ascending
}
);
This works until there is a null value for DueDate. What I'm trying to do is: if there is a null for DueDate don't apply that SortDescriptor, just move on to the next. So for example I have three results in the ListView with values in all columns, they get sorted by NumRejected first, then DueDate then Number. If I also have some results with no DueDate I want them to be sorted NumRejected then Number, ignoring the DueDate. These should be below the three with DueDates.
At the moment a null on DueDate is being treated as the lowest value for that column, so they are at the top of the list.
I think a DelegateSortDescriptor might be the way to go, but I can't find any examples how to use that.