Class NaturalSortComparer
Provides a string comparer wich is generally usable on all DataGridTextColumns.
The bound value must be a string.
Inheritance
Implements
Namespace: Sartorius.SAF.Presentation.Markup
Assembly: Sartorius.SAF.Presentation.dll
Syntax
public class NaturalSortComparer : MarkupExtension, IListSortComparer, IComparer, IComparer<object>
Remarks
A list of strings: "a3", "a1", "a10", "a12", "a2", "a11", is sorted to: "a1", "a2", "a3", "a11", "a12", "a13". Traditionally the default string comparer sort it to: "a1", "a11", "a12", "a13", "a2", "a3"
Examples
<DataGrid SAF:AttachedProperties.AllowCustomSort="True">
<DataGridTextColumn
Header="Name"
Binding="{Binding Name}"
SAF:AttachedProperties.CustomSortComparer="{SAF:NaturalSortComparer}"/>
</DataGrid>
<DataGrid SAF:AttachedProperties.AllowCustomSort="True">
<DataGridTextColumn
Header="Name"
Binding="{Binding Unit.Name}"
SAF:AttachedProperties.CustomSortComparer="{SAF:NaturalSortComparer ColumnPropertyPath=Unit.Name}"/>
</DataGrid>
Constructors
View SourceNaturalSortComparer()
Initializes a new instance of the NaturalSortComparer class.
Declaration
public NaturalSortComparer()
NaturalSortComparer(String)
Initializes a new instance of the NaturalSortComparer class.
Declaration
public NaturalSortComparer(string columnPropertyPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | columnPropertyPath | The column property path. |
Properties
View SourceColumnPropertyPath
Gets or sets the column property path.
Declaration
public string ColumnPropertyPath { get; set; }
Property Value
Type | Description |
---|---|
System.String |
SortDirection
Gets or sets the sort direction.
Declaration
public ListSortDirection SortDirection { get; set; }
Property Value
Type | Description |
---|---|
System.ComponentModel.ListSortDirection |
Methods
View SourceCompare(Object, Object)
Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
Declaration
public virtual int Compare(object x, object y)
Parameters
Type | Name | Description |
---|---|---|
System.Object | x | The first object to compare. |
System.Object | y | The second object to compare. |
Returns
Type | Description |
---|---|
System.Int32 | A signed integer that indicates the relative values of |
ProvideValue(IServiceProvider)
Provides the value.
Declaration
public override object ProvideValue(IServiceProvider serviceProvider)
Parameters
Type | Name | Description |
---|---|---|
System.IServiceProvider | serviceProvider | The service provider. |
Returns
Type | Description |
---|---|
System.Object |