2012-10-29 140 views
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,但沒有找到如何從列表通過數據綁定建立流程文檔。

回答

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> 
+0

感謝,它適合我 – psct