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

时间:2011-11-14 19:13:44

标签: c# wpf vb.net flowdocument

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

html to 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是一个普通的stackpanel。问题是flowdocumentscrollviewer使用整个宽度但看起来流文档只使用了大约40%

我在俯瞰什么?提前谢谢!

1 个答案:

答案 0 :(得分:0)

我发现了这个问题。我的xaml中有一个带有stackpanel的文档scrollviewer,因此无法正确呈现。我删除了这个并解决了这个问题。