简体   繁体   中英

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. Initially, only first 3 pages load and then on user scroll remaining pages start loading data.

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. Thank-you!

This is how I have done DataGrid column header sorting in my application-

<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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM