Making a DataGrid Column Header sortable in WPF using C#

后端 未结 1 905
孤街浪徒
孤街浪徒 2021-01-01 10:15

I am using C# in Visual Studio 2008 and I have install the WPF Toolkit. I created a DataGrid in testtest.xaml. The ID and Parts $ columns have the ability to sort the Dat

1条回答
  •  悲&欢浪女
    2021-01-01 10:49

    In your DataGridTemplateColumn you have SortMemberPath set to "". If you set this to an actual property on the item (say, CompleteDate), you should be able to sort. You can also set CanUserSort="true" or CanUserSort="false" on selected columns.

    SortMemberPath gives the property to sort on when the user attempts a sort. If this isn't set, then the grid doesn't know how to sort that column ( it does not use the text in the column)

                
                
                        
                            
                                
                                    
                                
                            
                        
                    
                
    

    0 讨论(0)
提交回复
热议问题