如何使用 ViewModel 对 silverlight 数据网格实现自然(人类字母数字)排序?
在使用数据网格的 silverlight 项目中,我使用一些定义“标签编号”的列,它是一个 Varchar。
我想按照自然排序顺序对此列进行排序,如中所述 “http://www.interact-sw.co.uk/iangblog/2007/12/13/natural-sorting”或任何可能的方式。
当我环顾数据网格时,我只看到了 SortMemberPath="stringProperty"。因此,我的排序只是像字符串排序一样工作。例如:
Z1
Z10
Z2
Z20
我希望它的排序如下:
Z1
Z2
Z10
Z20
在这方面提出建议将会有很大帮助。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于 ObservableCollection<> 的自然排序...,使用链接中定义的类比较集合的每一行(http://www.interact-sw.co.uk/iangblog/2007/12/13/natural-sorting)并刷新与数据网格的绑定。那行得通。
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.