C# 为什么';我的FlowDocument不使用整个宽度吗?

C# 为什么';我的FlowDocument不使用整个宽度吗?,c#,wpf,vb.net,flowdocument,C#,Wpf,Vb.net,Flowdocument,我正在将HTML转换为XAML,并使用FlowDocumentScrollViewer将其加载到StackPanel中。内容正在从HTML中正确呈现。我的问题是内容或流程文档似乎没有使用整个宽度 html到xaml的转换如下所示 <FlowDocument xml:space="preserve" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <Paragraph>Central Co

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

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)

中央承包商注册是免费的,不应该花你一分钱
中央承包商注册是免费的。联邦政府在中央承包商注册数据库中注册您的企业不收取费用。我告诉你们,中央承包商注册是免费的,因为有一些混乱,我想[…]
Dim conversionhtml作为字符串=“中央承包商注册是免费的,不应该花一分钱。中央承包商注册是免费的。联邦政府在中央承包商注册数据库中注册您的企业不收取费用。我告诉你,中央承包商注册是免费的,因为那里有一些混乱,我想[…]”
Dim fd As FlowDocument=DirectCast(Markup.XamlReader.Parse(conversionhtml),FlowDocument)
将fdr作为新的FlowDocumentScrollViewer()进行调整
fdr.Document=fd
FeedsDisplay.Children.Add(fdr)
feedsdisplay是一个普通的堆栈面板。问题是flowdocumentscrollviewer使用了整个宽度,但看起来flow文档只使用了大约40%


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

我发现了这个问题。我的xaml中有一个带有stackpanel的documentscrollviewer,因此它没有正确地重新启动。我删除了这个和那个,修复了这个问题。

添加
HorizontalAlignment=“Stretch“
到FlowDocument标记帮助?FlowDocument本身不允许水平对齐,但我尝试了PageWidth=horizontalAlignment.Stretch,结果相同