Search code examples
c#wpfvb.netflowdocument

Why doesn't my FlowDocument use the whole width?


I am converting HTML to XAML and loading it in a StackPanel with FlowDocumentScrollViewer. The content is rendering correctly from the HTML. My issue is the content or the FlowDocument does not appear to use the whole width.

The html to xaml conversion looks like this

<FlowDocument xml:space="preserve" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<Paragraph>Central Contractor Registration Is Free It Shouldn't Cost You A Dime </Paragraph>
<Paragraph>Central Contractor Registration is free. The federal government does not charge a fee to register your business in the central contractor registration database. I am telling you that central contractor registration is free because there is some confusion out there and I want to [...]  </Paragraph>
</FlowDocument>

Dim conversionhtml As String = "<FlowDocument xml:space=""preserve"" xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""><Paragraph>Central Contractor Registration Is Free It Shouldn't Cost You A Dime </Paragraph><Paragraph>Central Contractor Registration is free. The federal government does not charge a fee to register your business in the central contractor registration database. I am telling you that central contractor registration is free because there is some confusion out there and I want to [...]</Paragraph></FlowDocument>"
Dim fd As FlowDocument = DirectCast(Markup.XamlReader.Parse(conversionhtml), FlowDocument)
Dim fdr As New FlowDocumentScrollViewer()
fdr.Document = fd
FeedsDisplay.Children.Add(fdr)

feedsdisplay is a normal stackpanel. The issue is the flowdocumentscrollviewer uses the whole width but it looks like the flow document only uses about 40 %

What am I overlooking? Thanks in advance!


Solution

  • I found the issue. I had a documentscrollviewer with a stackpanel in my xaml so it was not renering correctly. I removed this and that fixed the issue.