Skip to content

Commit

Permalink
use field
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Miller committed Dec 16, 2024
1 parent 1b69031 commit 5749546
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Maui.DataGrid/DataGrid.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1449,11 +1449,11 @@ private bool CanSort(SortData? sortData)

private IEnumerable<object> GetSortedItems(IList<object> unsortedItems, SortData sortData)
{
var columnToSort = Columns[sortData.Index];
_sortedColumn ??= Columns[sortData.Index];

foreach (var column in Columns)
{
if (column == columnToSort)
if (column == _sortedColumn)
{
column.SortingOrder = sortData.Order;
column.SortingIconContainer.IsVisible = true;
Expand All @@ -1470,12 +1470,12 @@ private IEnumerable<object> GetSortedItems(IList<object> unsortedItems, SortData
switch (sortData.Order)
{
case SortingOrder.Ascendant:
_ = columnToSort.SortingIcon.RotateTo(0);
items = unsortedItems.OrderBy(x => x.GetValueByPath(columnToSort.PropertyName));
_ = _sortedColumn.SortingIcon.RotateTo(0);
items = unsortedItems.OrderBy(x => x.GetValueByPath(_sortedColumn.PropertyName));
break;
case SortingOrder.Descendant:
_ = columnToSort.SortingIcon.RotateTo(180);
items = unsortedItems.OrderByDescending(x => x.GetValueByPath(columnToSort.PropertyName));
_ = _sortedColumn.SortingIcon.RotateTo(180);
items = unsortedItems.OrderByDescending(x => x.GetValueByPath(_sortedColumn.PropertyName));
break;
case SortingOrder.None:
return unsortedItems;
Expand Down

0 comments on commit 5749546

Please sign in to comment.