Euclidez

Hello, may be you can help me with this. I've a Flowdocument with columns and text, I want to put an image in the last page occuping the more free space.

Any idea

Thanks a lot !!!



Re: Windows Presentation Foundation (WPF) flowdocument empty space

Siri Vellanki - MSFT

Does FlowDocument.Blocks.Add(new BlockUIContainer(image)) not work for you




Re: Windows Presentation Foundation (WPF) flowdocument empty space

Euclidez

The problem is that code line only attach a bloch with the width of a column. For example I have a 5 columns flowdocument and I have only text in the first column, I want to put the image in the others 4 columns.

Any idea Thanks a lot !!





Re: Windows Presentation Foundation (WPF) flowdocument empty space

Euclidez

any idea



Re: Windows Presentation Foundation (WPF) flowdocument empty space

Ben Ronco - MSFT

Try putting your Image in a Figure at the end of your document, anchor it to Content, and make the width 1 content.

Figure fig = new Figure(new BlockUiContainer(image));
fig.HorizontalAnchor = FigureHorizontalAnchor.ContentLeft;
fig.VerticalAnchor = FigureVerticalAnchor.ParagraphTop;
fig.Width = new FigureLength(1, FigureUnitType.Content);

FlowDocument.Blocks.Add(new Paragraph(fig));





Re: Windows Presentation Foundation (WPF) flowdocument empty space

Euclidez

Hello Ben thanks for your answer. The problem is that I've columns and like you say the image is only in the end of the text. For example I've five columns and only one of them has text then the Image only appear at the last point of the text, but not take all other free space of the 4 columns.

Any idea





Re: Windows Presentation Foundation (WPF) flowdocument empty space

Ben Ronco - MSFT

Not sure I understand your problem completely. If you put the image in a Figure you should be able to size across all the other columns. You must make sure that the Figure is anchored correcly though (to Content, i.e. ContentLeft). Otherwise you will not get the sizing you expect. (Anchoring a Figure to a position in the column and you can only make the Figure 1 column wide)

Another possibility is that the image is not sizing as you expect. Try putting a background color on the Figure and see if it is the Image that is not sizing correctly. If so, you need to adjust the sizing preoperties (width and/or height) or StretchDirection property of the image.





Re: Windows Presentation Foundation (WPF) flowdocument empty space

Euclidez

Hello, thanks for your answer. Here I have the code may be reflect more the problem.

<Window

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

x:Class="UntitledProject27.Window2"

x:Name="Window"

Title="Window2"

SizeChanged="fdpv_SizeChanged"

Width="640" Height="480">

<Grid x:Name="LayoutRoot">

<FlowDocumentPageViewer Margin="8,8,8,8" x:Name="fdpv" >

<FlowDocument x:Name="doc" ColumnWidth="80">

<Paragraph>From the da dkfj dlfj dlfj dlk fjdlkfj dlkfj dlkf dlkfj dlkfj dlkfj dlkfj lkdjf ojero eijrf oeijf ioejflkdjf ldjlkjlkjvlcjvlk cjv lkjcv lkjcv lkjcvlk jcv cv cv cv cv cv cv df df df dfer er er er fgf sfd gta, we notice that strawberries really do taste better than chocolate:</Paragraph>

<Paragraph>

<Figure x:Name="figura" Background="Red" HorizontalAnchor="ContentLeft">

<BlockUIContainer>

<Image Source="Images\\test_image.png" />

</BlockUIContainer>

</Figure>

</Paragraph>

</FlowDocument>

</FlowDocumentPageViewer>

</Grid>

</Window>

As you can see the problem is that the image go to the next page and leave me a free space in page one.

Any idea . The problem is I want to fill the greater free space in the last page of a flow document.

Thanks a lot !!!





Re: Windows Presentation Foundation (WPF) flowdocument empty space

Ben Ronco - MSFT

You won't be able to prevent this unless you restrict the height of the image and/or Figure. Still, you cannot guarantee that your Figure will not "delay" (a Figure will delay to the next page when it cannot fit on the page of its content anchor) to the next page unless your Page Size is fixed.

Try putting Height=".25 Content" on the Figure. Of course not you need to worry about the stretch and aspect ratio of the image.