为什么我的FlowDocument不使用整个宽度?

本文关键字:我的 FlowDocument 为什么 | 更新日期: 2023-09-27 18:14:27

我正在将HTML转换为XAML并在FlowDocumentScrollViewer的StackPanel中加载它。从HTML正确呈现内容。我的问题是内容或FlowDocument似乎没有使用整个宽度。

html到xaml的转换如下所示

<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是一个普通的堆栈面板。问题是flowdocumentscrollviewer使用整个宽度,但它看起来像流文档只使用约40%

我忽略了什么?提前感谢!

为什么我的FlowDocument不使用整个宽度?

我发现了这个问题。我有一个documentscrollviewer与一个堆栈面板在我的xaml,所以它没有正确渲染。