0

我想通过 DataBinding 从数据模型构建表,但没有找到如何去做。我有这样的数据:

1.type CustomObj with slots:
- id
- a
- b    
2. variable Content of type <List of CustomObj>

How to make a table like as below:

+--------------------+--------------------+--------------------+
|Identifier          |a slot              |b slot              |
+--------------------+--------------------+--------------------+
|'id from first eleme|'a from first elemen|b from first elemen |
|t                   |t                   |t                   |
+--------------------+--------------------+--------------------+
|...                 |...                 |...                 |
+--------------------+--------------------+--------------------+

我阅读了有关 FlowDocument 的信息,但没有找到如何通过 DataBinding 从 List 构建流文档。

4

1 回答 1

0

要实现您想要的,请使用DataGrid

创建一个ObservableCollection<CustomObj>并将 DataGrids 绑定ItemsSource到此 OC。

您的 DataGrid 可能如下所示:

<DataGrid ItemsSource="{Binding CustomObjList}">
    <DataGrid.Columns>
    <DataGridTextColumn Header="Identifier" Binding="{Binding id}" />
    <DataGridTextColumn Header="a Slot" Binding="{Binding a}" />
    <DataGridTextColumn Header="b Slot" Binding="{Binding b}" />
    </DataGrid.Columns>
</DataGrid>
于 2012-10-29T10:43:42.880 回答