我有一些代码可以绑定到observablecollection。问题是我只得到一行而不是获得几行(意味着显示可观察集合中的所有元素)。如何获取可观察集合的所有行?
<FlowDocumentScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" FontFamily="Arial" BorderThickness="0" >
<FlowDocument>
<Table Name="myTable" FontFamily="Calibri" BorderThickness="3" BorderBrush="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}" DataContext="{Binding}">
<Table.Columns>
<TableColumn/>
<TableColumn/>
<TableColumn/>
<TableColumn/>
<TableColumn/>
<TableColumn/>
<TableColumn/>
<TableColumn/>
<TableColumn/>
</Table.Columns>
<TableRowGroup DataContext="{Binding}">
<TableRow>
<TableCell>
<Paragraph>
<Run Text="{Binding Activity_Name}"/>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph>
<Run Text="{Binding Data_Type}"/>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph>
<Run Text="{Binding Insert_Succeeded}"/>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph>
<Run Text="{Binding Insert_Failed}"/>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph>
<Run Text="{Binding Update_Succeeded}"/>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph>
<Run Text="{Binding Update_Failed}"/>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph>
<Run Text="{Binding Delete_Succeeded}"/>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph>
<Run Text="{Binding Delete_Failed}"/>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph>
<Run Text="{Binding Skipped}"/>
</Paragraph>
</TableCell>
<TableRow>
</TableRowGroup>
</Table>
</FlowDocument>
</FlowDocumentScrollViewer>
答案 0 :(得分:1)
FlowDocument控件不支持DataBinding,如here
所述虽然流程文档中有很多很棒的功能,但是如果你的话 文档是从动态数据生成的,你有一点点 问题:流文档中不支持数据绑定。 流文档元素(Section,Table,Run,Paragraph和 like)是依赖项对象,但不定义任何依赖项 允许您动态更改或生成的属性 内容。
上述链接有一个解决方法,可能对您有所帮助。