- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我想在启动时指定默认顺序,但仍允许用户通过单击列标题进行排序。遗憾的是,SortDirection 属性在设置时会被忽略 - 即我们得到了正确的列标题箭头,但没有任何内容被排序。
手动点击标题,正确排序数据,所以它不是排序本身。这是我使用的简化版本:
<DataGrid ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=CurrentView}" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Header 1" Binding="{Binding ApplicationName}"/>
<DataGridTextColumn Header="Header 2"
Binding="{Binding TotalTime}" SortDirection="Descending"/>
</DataGrid.Columns>
</DataGrid>
更新:我还尝试按照建议将 SortDescriptions 添加到 ICollectionView,但没有取得好的结果。这可能与我正在向集合中动态添加新项目这一事实有关吗? IE。在启动时,列表是空的并且慢慢填充,也许 sortdescription 只应用了一次?
最佳答案
看看这个MSDN Blog
来自上面的链接:
DataGridColumn.SortDirection does not actually sort the column.
DataGridColumn.SortDirection is used to queue the visual arrow in the DataGridColumnHeader to point up, down, or to not show. To actually sort the columns other than clicking on the DataGridColumnHeader, you can set the DataGrid.Items.SortDescriptions programmatically.
关于c# - DataGrid SortDirection 被忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8556302/
我想在启动时指定默认顺序,但仍允许用户通过单击列标题进行排序。遗憾的是,SortDirection 属性在设置时会被忽略 - 即我们得到了正确的列标题箭头,但没有任何内容被排序。 手动点击标题,正确排
我有一个 gridview,当用户单击标题时,我需要对其元素进行排序。 它的数据源是一个List对象。 aspx 是这样定义的:
我正在处理一个 ListView 并且感觉在实现排序时我做的事情根本上是错误的。我无法依赖于 List1.SortExpression 和 List1.SortDirection 的值,而是求助于隐藏
我正在尝试使用 MVCGrid.Net 设置网格,但使用排序的代码给我带来了 options.sortdirection 错误。 public static void RegisterGrids()
我是一名优秀的程序员,十分优秀!