ResetTo() public method

Resets sort to one column assuming default (ascending) order. Typically called as a result of click on one of the column headers which clears current sort across all columns and sets the clicked column as primary with the default sorting order.
public ResetTo ( HeaderTextVisual v ) : void
v HeaderTextVisual
return void
Esempio n. 1
0
 protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
 {
     if (Header)
     {
         var pt = e.GetPosition(this);
         foreach (var viz in _visualChildren)
         {
             var v = viz as HeaderTextVisual;
             if (v != null)
             {
                 Rect rc = new Rect(v.X, v.Y, v.Size.Width, v.Size.Height);
                 if (rc.Contains(pt))
                 {
                     // Order: None -> Ascending -> Descending -> Ascending -> Descending -> ...
                     v.ToggleSortOrder();
                     if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
                     {
                         // Shift+Click adds column to the sorting set.
                         _sortOrder.Add(v);
                     }
                     else
                     {
                         // Clear all column sorts except the one that was clicked on.
                         ResetSortToPrimary(v);
                         _sortOrder.ResetTo(v);
                     }
                     SortOrderChanged?.Invoke(this, EventArgs.Empty);
                     break;
                 }
             }
         }
     }
     // Find out which visual is it
     base.OnPreviewMouseDown(e);
 }
Esempio n. 2
0
 public void ToggleSort(HeaderTextVisual v, bool add)
 {
     // Order: None -> Ascending -> Descending -> Ascending -> Descending -> ...
     v.ToggleSortOrder();
     if (add)
     {
         // Shift+Click adds column to the sorting set.
         _sortOrder.Add(v);
     }
     else
     {
         // Clear all column sorts except the one that was clicked on.
         ResetSortToPrimary(v);
         _sortOrder.ResetTo(v);
     }
     SortOrderChanged?.Invoke(this, EventArgs.Empty);
 }