我想通过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构建流文档。
答案 0 :(得分: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>