我正在使用此处找到的可绑定FlowDocument项控件:
http://msdn.microsoft.com/en-us/magazine/dd569761.aspx
它像宣传的那样完美;但是,我希望扩展它。我希望能够为ItemsPanel指定ItemsPresenter,就像对ItemsControl一样。我的目标是在桌子上加一个页脚。
使用网站上的示例:
<flowdoc:ItemsContent ItemsSource="{Binding Source= {StaticResource DataSource},XPath=FortressGuys/Person}" >
<flowdoc:ItemsContent.ItemsPanel>
<DataTemplate>
<flowdoc:Fragment>
<Table BorderThickness="1" BorderBrush="Black">
<TableRowGroup flowdoc:Attached.IsItemsHost="True">
<TableRow Background="LightBlue">
<TableCell>
<Paragraph>First name</Paragraph>
</TableCell>
<TableCell>
<Paragraph>Last name</Paragraph>
</TableCell>
</TableRow>
</TableRowGroup>
<TableRowGroup>
<!-- ITEMS PRESENTER -->
</TableRowGroup>
<TableRowGroup>
<TableRow>
<TableCell>
<Paragraph>My Amazing Footer</Paragraph>
</TableCell>
</TableRow>
</TableRowGroup>
</Table>
</flowdoc:Fragment>
</DataTemplate>
</flowdoc:ItemsContent.ItemsPanel>
<flowdoc:ItemsContent.ItemTemplate>
<DataTemplate>
<flowdoc:Fragment>
<TableRow>
<TableCell>
<Paragraph>
<flowdoc:BindableRun BoundText="{Binding XPath=@FirstName}" />
</Paragraph>
</TableCell>
<TableCell>
<Paragraph>
<flowdoc:BindableRun BoundText="{Binding XPath=@LastName}"/>
</Paragraph>
</TableCell>
</TableRow>
</flowdoc:Fragment>
</DataTemplate>
</flowdoc:ItemsContent.ItemTemplate>
</flowdoc:ItemsContent>
最终看起来像这样:
First Name Last Name
----------------------
Nancy Davolio
Andrew Fuller
----------------------
My Awesome Footer
有谁知道如何实现这一目标?
答案 0 :(得分:4)
在进一步审查之后,我找到了答案。 IsItemsHost属性告诉控件放置项目的位置。
flowdoc:Attached.IsItemsHost="True"
从第一个TableRowGroup中删除该属性,并将其添加到第二行组:
<TableRowGroup flowdoc:Attached.IsItemsHost="True">
<!-- ITEMS PRESENTER -->
</TableRowGroup>