@@ -70,25 +70,30 @@ private void OnWidthChanged(DependencyObject sender, DependencyProperty dp)
70
70
/// </summary>
71
71
private void DoSort ( SD ? direction , bool singleSorting = true )
72
72
{
73
- if ( CanSort && Column is not null && _tableView is not null )
73
+ if ( CanSort && Column is not null && _tableView is { CollectionView : CollectionView { } collectionView } )
74
74
{
75
- if ( singleSorting )
75
+ var defer = collectionView . DeferRefresh ( ) ;
76
76
{
77
- _tableView . ClearAllSortingWithEvent ( ) ;
77
+ if ( singleSorting )
78
+ {
79
+ _tableView . ClearAllSortingWithEvent ( ) ;
80
+ }
81
+ else
82
+ {
83
+ ClearSortingWithEvent ( ) ;
84
+ }
85
+
86
+ if ( direction is not null )
87
+ {
88
+ var boundColumn = Column as TableViewBoundColumn ;
89
+ Column . SortDirection = direction ;
90
+ _tableView . SortDescriptions . Add (
91
+ new ColumnSortDescription ( Column ! , boundColumn ? . PropertyPath , direction . Value ) ) ;
92
+
93
+ _tableView . EnsureAlternateRowColors ( ) ;
94
+ }
78
95
}
79
- else
80
- {
81
- ClearSortingWithEvent ( ) ;
82
- }
83
-
84
- if ( direction is null ) return ;
85
-
86
- var boundColumn = Column as TableViewBoundColumn ;
87
- Column . SortDirection = direction ;
88
- _tableView . SortDescriptions . Add (
89
- new ColumnSortDescription ( Column ! , boundColumn ? . PropertyPath , direction . Value ) ) ;
90
-
91
- _tableView . EnsureAlternateRowColors ( ) ;
96
+ defer . Complete ( ) ;
92
97
}
93
98
}
94
99
@@ -222,7 +227,7 @@ protected override void OnApplyTemplate()
222
227
_searchBox . PlaceholderText = TableViewLocalizedStrings . SearchBoxPlaceholder ;
223
228
_searchBox . TextChanged += OnSearchBoxTextChanged ;
224
229
#if WINDOWS
225
- _searchBox . PreviewKeyDown += OnSearchBoxKeyDown ;
230
+ _searchBox . PreviewKeyDown += OnSearchBoxKeyDown ;
226
231
#else
227
232
_searchBox . KeyDown += OnSearchBoxKeyDown ;
228
233
#endif
0 commit comments