开发者

WPF FlowDocument with ItemsPresenter

I am using the bindable FlowDo开发者_如何学Pythoncument 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?


After reviewing it further, I found the answer. The IsItemsHost attribute tells the control where to place the items.

 flowdoc:Attached.IsItemsHost="True"

Remove that attribute from the first TableRowGroup and add it to the second row group:

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

            <!-- ITEMS PRESENTER -->

            </TableRowGroup>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜