我发现很多线程都带有上面的关键字,但大多数人都要求排序。我要求在初始化时刻排序。如果加载了表单,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