WPF FlowDocument with Presenter Elements

I am using the bindable FlowDocument control found here:

http://msdn.microsoft.com/en-us/magazine/dd569761.aspx

It works great as advertised; however, I was hoping to expand it. I want to specify the ItemsPresenter for the ItemsPanel, the same as for the 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>

What in the end would look something like this:

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

Does anyone know how this will be achieved?

+3
source share
1 answer

After considering this question, I found the answer. The IsItemsHost attribute tells the control where to place the elements.

 flowdoc:Attached.IsItemsHost="True"

Remove this attribute from the first TableRowGroup and add it to the second group of rows:

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

            <!-- ITEMS PRESENTER -->

            </TableRowGroup>
+4
source

Source: https://habr.com/ru/post/1795571/


All Articles