如何实现自然(人类字母数字)排序,对于Silverlight datagrids使用ViewModel? [英] How to achieve Natural(human alpha-numeric ) Sorting, for silverlight datagrids using ViewModel?

查看:192
本文介绍了如何实现自然(人类字母数字)排序,对于Silverlight datagrids使用ViewModel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用datagrid的silverlight项目中,我使用一些定义标签号的列,这是一个Varchar。



我想按照或以任何可能的方式描述在
http://www.interact-sw.co.uk/iangblog/2007/12/13/natural-sorting中描述的自然排序顺序。



当我查看datagrid时,我看到SortMemberPath =stringProperty。因此,我的排序只是像字符串排序一样工作。例如:



Z1



Z10



Z2



Z20



我希望将其排序如下:



Z1



Z2



Z10



Z20



在这方面提出建议将是非常有帮助的。

解决方案

对于ObservableCollection<> ...的自然排序,使用链接中定义的类来比较Collection的每一行( http://www.interact-sw.co.uk/iangblog/2007/12/13/natural-sorting )并刷新与datagrid绑定。这很有效。


In silverlight project that uses datagrid, I am using some column that defines "Label number" which is a Varchar.

I want to sort this column as described in natural sort order as described in "http://www.interact-sw.co.uk/iangblog/2007/12/13/natural-sorting" or any possible way.

When I look around datagrid I saw SortMemberPath="stringProperty" only. Hence, my sorting is just working like string sorting only. For example:

Z1

Z10

Z2

Z20

where as I want it to sort like:

Z1

Z2

Z10

Z20

It will be of great help to have suggestion on this regard.

解决方案

For Natural sorting of ObservableCollection<> ..., Compare each row of the Collection using class defined in link(http://www.interact-sw.co.uk/iangblog/2007/12/13/natural-sorting) and refresh the binding with datagrid. That worked.

这篇关于如何实现自然(人类字母数字)排序,对于Silverlight datagrids使用ViewModel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆