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

发布于 2024-12-15 11:27:01 字数 1627 浏览 1 评论 0原文

我正在将 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 使用整个宽度,但看起来 flow document 仅使用大约 40 %

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

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

遗弃M 2024-12-22 11:27:01

我发现了这个问题。我的 xaml 中有一个带有堆栈面板的文档滚动查看器,因此它无法正确重新生成。我删除了这个并解决了问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文