[英]Sorting datagrid in WPF based on click of column header
I am using a datagrid which is binded to an observable collection. 我正在使用绑定到可观察集合的数据网格。 The grid is divided into pages and each page holds 50 records.
网格分为几页,每页包含50条记录。 Initially, only first 3 pages load and then on user scroll remaining pages start loading data.
最初,仅加载前3页,然后在用户滚动时,其余页面开始加载数据。
The problem is when I click on column header to sort data, the data of only first page sorts even if there is data for first 2 pages. 问题是,当我单击列标题以对数据进行排序时,即使有前两页的数据,也只会对第一页的数据进行排序。 And when I again click on column header then all 100 rows ie data for both the pages are sorted instead of just the first page.
当我再次单击列标题时,将对所有100行(即两个页面的数据)进行排序,而不仅仅是第一页。 Thank-you!
谢谢!
This is how I have done DataGrid column header sorting in my application- 这就是我在应用程序中完成DataGrid列标题排序的方式-
<dgCP:DataGridTemplateColumn SortMemberPath="CompleteDate" Header="Complete Date" CanUserSort="true">
<dgCP:DataGridTemplateColumn.CellTemplate >
<DataTemplate>
<TextBlock>
<TextBlock.Text>
<Binding Path="CompleteDate" StringFormat="{}{0:MM/dd/yyyy}"/>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</dgCP:DataGridTemplateColumn.CellTemplate>
</dgCP:DataGridTemplateColumn>
see if this helps. 看看是否有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.