/wpf-extensions

Extensions for the WPF Controls

Primary LanguageC#MIT LicenseMIT

WPF Extensions

NuGet GitHub

Custom Grid Sorting

Without Custom Sorting Custom Sorting
no custom sorting custom sorting

Usage

  1. Enable custom sorting for DataGrid by UseCustomSort
  2. Set CustomSorter or CustomSorterType for columns you want apply custom sorting.
    • Sorter must implement IComparer
    • Sorter must have default constructor in order to use CustomSorterType
<DataGrid attached:DataGridHelpers.UseCustomSort="True" ItemsSource="{Binding Items}" AutoGenerateColumns="False">
    <DataGrid.Columns>
        <DataGridTextColumn attached:DataGridHelpers.CustomSorterType="{x:Type comparers:StrLogicalComparer}" Binding="{Binding CodeText}" Header="Code"  />
        <DataGridTextColumn Header="Number" Binding="{Binding Number}" />
    </DataGrid.Columns>
</DataGrid>

Supports Nested Properties

<DataGrid attached:DataGridHelpers.UseCustomSort="True" ItemsSource="{Binding Items}" AutoGenerateColumns="False">
    <DataGrid.Columns>
        <DataGridTextColumn Binding="{Binding Item.Item1.Item2.TextNumber}" Header="Code" 
                            attached:DataGridHelpers.CustomSorterType="{x:Type comparers:StrLogicalComparer}" />
    </DataGrid.Columns>
</DataGrid>

Extensions

Licence

MIT License (MIT)