如何为 Windows Phone 创建具有两列且 header 的可滚动 table?

How to create scrollable table with two columns with header for Windows Phone?

我有一个看似很简单的需求:我想创建一个带有两个headers的可滚动table/gridbox/gridview。 table 应该绑定一个名为 DataSet 的数据集,其中包含 objects 的 collection,属性为 Column1Column2。此外,table 的 body 应该可以垂直滚动。请参见下图。

虽然这看起来很简单,但我做不到。

我尝试使用顶部有两个 TextBlocksListBox 控件,但这看起来很难看(因为 headers 没有正确对齐并且不是 [=40= 的一部分]).而且我确信有一个我还没有找到的更好的解决方案。

谁能告诉我如何创建一个像上面描述的网格,它绑定了一个名为 DataSet 的数据集,其中有 Column1Column2,其中 body可以垂直滚动吗?

我会在列表视图中使用嵌入式堆栈面板。因此,您有一个可滚动的堆栈,您可以在其中填充信息。然后在 headers.

顶部使用文本块

下面的 XAML 纯粹是示例,可能效果不佳。

<ListView x:Name="NameofList">
                    <ListView.DataContext>
                        <Put in your object type! (Maybe a mapped class?)>
                    </ListView.DataContext>
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <StackPanel x:Name="stackList"
                                        Grid.ColumnSpan="2"
                                        Width="595"
                                        Height="59"
                                        HorizontalAlignment="Left"
                                        BorderBrush="#FF595050"
                                        BorderThickness="0,1">
                                <TextBlock x:Name="tbListName"
                                           FontWeight="Bold"
                                           Text="{Binding Name}" />
                                <TextBlock x:Name="tbListDate"
                                           FontWeight="Bold"
                                           Text="{Binding Date}" />
                                <TextBlock x:Name="tbListNote1"
                                           FontWeight="Bold"
                                           Text="{Binding Number}" />
                            </StackPanel>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                    <Your object! />
                </ListView>