Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2150
Visual Indication of Multi-Column Sorting Priority
posted

In the WPF XamGrid is there a way to get a the sort indicator in the header to also show the sorting priority?  

In other words, if I'm sorting ascending on two columns, can I get the XamGrid column to show me which is sorted first and which is second?  I understand this type of feature is available in some IG datagrids, but maybe not this one.

I'd rather not re-invent the wheel if I'm overlooking something that already exists.  Even a tooltip would probably be sufficient (eg.  hovering over the sort indicator would show the sorting priority of the grid).

If I have to do this manually I'm thinking I'd create a new template for the column header, and try a tooltip approach.  Please let me know if there are any suggestions along this line.  Ideally I'd be looking for an approach that's not too elaborate since this confusion over sorting behavior doesn't come up all that frequently.

Parents
No Data
Reply
  • 34810
    Verified Answer
    Offline posted

    Hello dbeavon,

    Thank you for your post.

    I have been investigating into this issue, and I would recommend that you begin by including the default style for HeaderCellControl. This element is what makes up the headers in the XamGrid, and its default style can be found in the generic.shared.xaml file commonly found at the following directory: C:\Program Files (x86)\Infragistics\<your version here>\WPF\DefaultStyles\XamGrid.

    The template of the HeaderCellControl contains a Grid element named "SortAndPinIndicators." This is where I would recommend placing your tooltip, or other customization to the grid. The sort priority of the XamGrid columns will correspond directly to the index of that column in the XamGrid.SortingSettings.SortedColumns collection. Knowing this, I would recommend a MultiBinding for the Tooltip property of that "SortAndPinIndicators" grid, along with an IMultiValueConverter. These bindings can be to the HeaderCellControl (template parent), and the HeaderCellControl's Column.IsSorted property. The second bit is to ensure that the converter's Convert method will fire when the IsSorted property of a specific column changes.

    Using the HeaderCellControl in the converter, you can obtain the XamGrid from that HeaderCellControl, and then use the XamGrid.SortingSettings.SortedColumns.IndexOf(HeaderCellControl.Column) method to find the index that the column exists in for the sorted columns collection of the XamGrid. Then, you can return a tooltip string based on that index.

    I have attached a sample project to demonstrate the above. I hope this helps you.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer
    Infragistics Inc.
    www.infragistics.com/support

    XamGridSortPriorityCase.zip
Children