使在列标题点击WPF的ListView / GridView中排序的最佳方式? [英] Best way to make WPF ListView/GridView sort on column-header clicking?

查看:428
本文介绍了使在列标题点击WPF的ListView / GridView中排序的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

地段的。我至于什么是最好的方式真的很困惑。比如......我希望这是有点向上/向下箭头在列标题来指示排序方向。有明显喜欢3种不同的方式来做到这一点,一些使用code,一些使用标记,有的使用标记加锁code,和所有似乎有点像黑客攻击。

There are lots of solutions on the internet attempting to fill this seemingly very-basic omission from WPF. I'm really confused as to what would be the "best" way. For example... I want there to be little up/down arrows in the column header to indicate sort direction. There are apparently like 3 different ways to do this, some using code, some using markup, some using markup-plus-code, and all seeming rather like a hack.

有没有人遇到这个问题之前,并找到了解决办法,他们是具有完全幸福吗?看来奇怪的是这样一个基本的WinForms一块的功能是从WPF丢失,需要进行破解。

Has anyone run into this problem before, and found a solution they are completely happy with? It seems bizarre that such a basic WinForms piece of functionality is missing from WPF and needs to be hacked in.

推荐答案

这一切都取决于真的,如果你正在使用从WPF工具包DataGrid中则有一个内置的排序,甚至多列排序,这是非常有用。检查多出在这里:

It all depends really, if you're using the DataGrid from the WPF Toolkit then there is a built in sort, even a multi-column sort which is very useful. Check more out here:

<一个href=\"http://blogs.msdn.com/vinsibal/archive/2008/08/29/wpf-datagrid-tri-state-sorting-sample.aspx\">Vincent Sibals博客

另外,如果您使用的是不同的控制,不支持排序,我推荐以下方法:

Alternatively, if you're using a different control that doesn't support sorting, i'd recommend the following methods:

梨膏的自定义​​排序

其次是:

梨膏的快速排序

这篇关于使在列标题点击WPF的ListView / GridView中排序的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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