Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

This example shows how to perform sorting using custom comparer in XForms ListView control.

NotificationsYou must be signed in to change notification settings

SyncfusionExamples/xamarin-forms-listview-custom-sorting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

Xamarin Forms ListView provides support to custom sort the items using Comparer.

Sample

<sync:SfListViewx:Name="listView"ItemSize="70"FocusBorderThickness="0"SelectionBackgroundColor="#ECECEC"IsScrollBarVisible="False"ItemsSource="{Binding ContactsInfo}">        <sync:SfListView.DataSource>        <dataSource:DataSource>            <dataSource:DataSource.SortDescriptors>                <dataSource:SortDescriptor>                    <dataSource:SortDescriptor.Comparer>                        <local:CustomSortComparer/>                    </dataSource:SortDescriptor.Comparer>                </dataSource:SortDescriptor>            </dataSource:DataSource.SortDescriptors>        </dataSource:DataSource>    </sync:SfListView.DataSource>        <sync:SfListView.ItemTemplate>        <DataTemplate>            <ViewCell>                <ViewCell.View>                    <code>                    . . .                    . . .                    <code>                </ViewCell.View>            </ViewCell>        </DataTemplate>    </sync:SfListView.ItemTemplate></sync:SfListView>CustomSortComparer:public class CustomSortComparer : IComparer<object>{    public int Compare(object x, object y)    {        if (x.GetType() == typeof(ListViewContactsInfo))        {            var xitem = (x as ListViewContactsInfo).ContactName;            var yitem = (y as ListViewContactsInfo).ContactName;            if (xitem.Length > yitem.Length)            {                return 1;            }            else if (xitem.Length < yitem.Length)            {                return -1;            }            else            {                if (string.Compare(xitem, yitem) == -1)                    return -1;                else if (string.Compare(xitem, yitem) == 1)                    return 1;            }        }        return 0;    }}

About

This example shows how to perform sorting using custom comparer in XForms ListView control.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors7

Languages


[8]ページ先頭

©2009-2025 Movatter.jp