menu

MAUI

  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class SortDescriptor - MAUI API Reference | Syncfusion

    Show / Hide Table of Contents

    Class SortDescriptor

    Represents a sort descriptor that defines the sorting criteria for SfTreeView.

    Inheritance
    System.Object
    SortDescriptor
    Namespace: Syncfusion.TreeView.Engine
    Assembly: Syncfusion.Maui.TreeView.dll
    Syntax
    public class SortDescriptor : BindableObject

    Constructors

    SortDescriptor()

    Initializes a new instance of the SortDescriptor class.

    Declaration
    public SortDescriptor()

    Fields

    ComparerProperty

    Identifies the Comparer bindable property.

    Declaration
    public static readonly BindableProperty ComparerProperty
    Field Value
    Type
    Microsoft.Maui.Controls.BindableProperty

    DirectionProperty

    Identifies the Direction bindable property.

    Declaration
    public static readonly BindableProperty DirectionProperty
    Field Value
    Type
    Microsoft.Maui.Controls.BindableProperty

    PropertyNameProperty

    Identifies the PropertyName bindable property.

    Declaration
    public static readonly BindableProperty PropertyNameProperty
    Field Value
    Type
    Microsoft.Maui.Controls.BindableProperty

    Properties

    Comparer

    Gets or sets a custom comparer for the sort operation.

    Declaration
    public IComparer<object> Comparer { get; set; }
    Property Value
    Type Description
    System.Collections.Generic.IComparer<System.Object>

    An implementation of the System.Collections.IComparer interface. The default is null.

    Remarks

    The Comparer property allows you to provide custom comparison logic for sorting. When specified, this comparer is used instead of the default comparison based on the property value.

    Examples
    // Custom comparer implementation
    public class CustomComparer : IComparer
    {
        public int Compare(object x, object y)
        {
            // Custom comparison logic
            return string.Compare(x?.ToString(), y?.ToString());
        }
    }
    // Using the custom comparer
    sortDescriptor.Comparer = new CustomComparer();

    Direction

    Gets or sets the direction of the sort operation.

    Declaration
    public TreeViewSortDirection Direction { get; set; }
    Property Value
    Type Description
    TreeViewSortDirection

    One of the values. The default is .

    Remarks

    The Direction property determines whether items are sorted in ascending or descending order.

    Examples
    <treeView:SortDescriptor Direction="Descending" />
    sortDescriptor.Direction = SortDirection.Descending;

    PropertyName

    Gets or sets the name of the property used for sorting.

    Declaration
    public string PropertyName { get; set; }
    Property Value
    Type Description
    System.String

    The name of the property to sort by. The default value is an empty string.

    Remarks

    The PropertyName can be a simple property name (e.g., "Name") or a complex property path (e.g., "Contact.Address.City").

    Examples
    <treeView:SortDescriptor PropertyName="Name" />
    sortDescriptor.PropertyName = "Name";
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved