Show / Hide Table of Contents

Class NaturalSortComparer

Provides a string comparer wich is generally usable on all DataGridTextColumns.
The bound value must be a string.

Inheritance
System.Object
System.Windows.Markup.MarkupExtension
NaturalSortComparer
Implements
IListSortComparer
System.Collections.IComparer
System.Collections.Generic.IComparer<System.Object>
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
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 Source

NaturalSortComparer()

Initializes a new instance of the NaturalSortComparer class.

Declaration
public NaturalSortComparer()
View Source

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 Source

ColumnPropertyPath

Gets or sets the column property path.

Declaration
public string ColumnPropertyPath { get; set; }
Property Value
Type Description
System.String
View Source

SortDirection

Gets or sets the sort direction.

Declaration
public ListSortDirection SortDirection { get; set; }
Property Value
Type Description
System.ComponentModel.ListSortDirection

Methods

View Source

Compare(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 x and y, as shown in the following table.Value Meaning Less than zero x is less than y. Zero x equals y. Greater than zero x is greater than y.

View Source

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
Overrides
System.Windows.Markup.MarkupExtension.ProvideValue(System.IServiceProvider)

Implements

IListSortComparer
System.Collections.IComparer
System.Collections.Generic.IComparer<T>

Extension Methods

CollectionExtensions.AddRange<T, TCollection>(TCollection, IEnumerable<T>)
SerializableObjectCloneExtension.Clone<T>(T)
  • View Source
Back to top Generated by DocFX