带有 ItemsPresenter 的 WPF FlowDocument
我正在使用此处找到的可绑定 FlowDocument 项目控件:
http://msdn.microsoft。 com/en-us/magazine/dd569761.aspx
它的效果与广告中的一样完美;然而,我希望能够扩展它。我希望能够为 ItemsPanel 指定 ItemsPresenter,就像为 ItemsControl 指定 ItemsPresenter 一样。我的目标是为表格添加页脚。
使用网站上的示例:
<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
有谁知道这是如何实现的?
I am using the bindable FlowDocument items control found here:
http://msdn.microsoft.com/en-us/magazine/dd569761.aspx
It works perfectly as advertised; however, I was hoping to expand on it. I want to be able to specify an ItemsPresenter for the ItemsPanel, the same way you would for an ItemsControl. My goal is to include a footer for the table.
Using the example on the site:
<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>
Which would ultimately look something like this:
First Name Last Name
----------------------
Nancy Davolio
Andrew Fuller
----------------------
My Awesome Footer
Does anyone know how this would be accomplished?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
进一步查看后,我找到了答案。 IsItemsHost 属性告诉控件将项目放置在何处。
从第一个 TableRowGroup 中删除该属性并将其添加到第二个行组:
After reviewing it further, I found the answer. The IsItemsHost attribute tells the control where to place the items.
Remove that attribute from the first TableRowGroup and add it to the second row group: