我发现很多带有上述关键字的线程,但大多数人都要求排序。我要求在初始化时刻进行排序。如果加载了表单,则 GridView 应该已经按特定列排序。如果可能在 XAML 中。
现在的默认情况,我不需要:
加载表单时我希望拥有的默认情况:
知道怎么做吗?
<sdk:DataGrid x:Name="dgv"
ItemsSource="{Binding}"
>
<sdk:DataGrid.Resources>
<CollectionViewSource x:Key="PrioritySorter" Source="{Binding .}">
<CollectionViewSource.SortDescriptions>
????? How to sort by "Active" property ASC?
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
</sdk:DataGrid.Resources>
<sdk:DataGrid.Columns >
<sdk:DataGridTextColumn
Header="N°"
Binding="{Binding Id}"
IsReadOnly="True"/>
<sdk:DataGrid.Columns >
<sdk:DataGridTextColumn
Header="Priority"
Binding="{Binding Priority}" />
<sdk:DataGrid.Columns >
<sdk:DataGridTextColumn
Header="Active"
Binding="{Binding Id}" />
* 解决方案 *
Private Sub Service_GetItemsCompleted(sender As Object, e As ServiceReference1.GetItemsCompletedEventArgs) Handles Service.GetItemsCompleted
'Me.Items = e.Result
Dim pageView As New PagedCollectionView(e.Result)
pageView.SortDescriptions.Add(New SortDescription("Rights", ListSortDirection.Ascending))
Me.dgv1.DataContext = pageView
End Sub