在XAML中我有:
<ListView x:Name="ListView1" />
在代码背后我有:
Private Sub BuildList()
For i As Integer = 1 To 5
Dim a1 As New Border With {.Background = New SolidColorBrush(Windows.UI.Colors.DarkOrange), .Padding = New Thickness(5, 15, 5, 15), .Margin = New Thickness(0, 0, 0, 10)}
Dim b1 As New TextBlock With {.Text = i, .FontSize = 30, .TextLineBounds = TextLineBounds.Tight}
a1.Child = b1
Dim c1 As New GroupItem With {.Content = a1}
ListView1.Items.Add(c1)
For j As Integer = 1 To 5
Dim a2 As New Border With {.Background = New SolidColorBrush(Windows.UI.Colors.DarkOliveGreen), .Padding = New Thickness(20, 10, 0, 10), .Margin = New Thickness(0, 0, 0, 10)}
Dim b2 As New TextBlock With {.Text = i, .FontSize = 20, .TextLineBounds = TextLineBounds.Tight}
a2.Child = b2
ListView1.Items.Add(a2)
Next
Next
Debug.WriteLine(ListView1.IsGrouping.ToString)
End Sub
可悲的是,IsGrouping返回false并且标题不会像滚动时那样粘在顶部。
PS:请不要讲道如何绑定到CollectionViewsource。