2011-03-01 42 views
3

我现在用的是绑定的FlowDocument项的控制这里找到:WPF的FlowDocument与ItemsPresenter

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 [email protected]}" /> 
        </Paragraph> 
       </TableCell> 
       <TableCell> 
        <Paragraph> 
         <flowdoc:BindableRun BoundText="{Binding [email protected]}"/> 
        </Paragraph> 
       </TableCell> 
      </TableRow> 
     </flowdoc:Fragment> 
    </DataTemplate> 
</flowdoc:ItemsContent.ItemTemplate> 
</flowdoc:ItemsContent> 

这最终是这个样子:

First Name Last Name 
---------------------- 
Nancy  Davolio 
Andrew  Fuller 
---------------------- 
My Awesome Footer 

有谁知道如何做到这一点来实现?

回答

4

在进一步审查后,我找到了答案。 IsItemsHost属性告诉控件放置项目的位置。

flowdoc:Attached.IsItemsHost="True" 

从第一TableRowGroup删除属性,并将其添加到第二行组:

  <TableRowGroup flowdoc:Attached.IsItemsHost="True"> 

      <!-- ITEMS PRESENTER --> 

      </TableRowGroup>