gpt4 book ai didi

c# - XAML 到 HTML 的转换 - WPF RichTextBox

转载 作者:太空宇宙 更新时间:2023-11-04 13:57:40 26 4
gpt4 key购买 nike

我有一个 WPF RichTextBox 问题,我正在提取它的 XAML 代码并将其保存到一个 txt 文件。当我将生成的 XAML 代码复制粘贴到像这样的 XAMLtoHTML 转换器时 http://blogs.msdn.com/wpfsdk/archive/2006/05/25/606317.aspx ,一定是出现了一些错误,因为我总是得到一个空白结果!

如果我写test在 RichTextBox 中,我得到以下 XAML:

<Section xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xml:space="preserve" TextAlignment="Left" LineHeight="Auto" IsHyphenationEnabled="False" xml:lang="en-us" FlowDirection="LeftToRight" NumberSubstitution.CultureSource="Text" NumberSubstitution.Substitution="AsCulture" FontFamily="Segoe UI" FontStyle="Normal" FontWeight="Normal" FontStretch="Normal" FontSize="12" Foreground="#FF000000" Typography.StandardLigatures="True" Typography.ContextualLigatures="True" Typography.DiscretionaryLigatures="False" Typography.HistoricalLigatures="False" Typography.AnnotationAlternates="0" Typography.ContextualAlternates="True" Typography.HistoricalForms="False" Typography.Kerning="True" Typography.CapitalSpacing="False" Typography.CaseSensitiveForms="False" Typography.StylisticSet1="False" Typography.StylisticSet2="False" Typography.StylisticSet3="False" Typography.StylisticSet4="False" Typography.StylisticSet5="False" Typography.StylisticSet6="False" Typography.StylisticSet7="False" Typography.StylisticSet8="False" Typography.StylisticSet9="False" Typography.StylisticSet10="False" Typography.StylisticSet11="False" Typography.StylisticSet12="False" Typography.StylisticSet13="False" Typography.StylisticSet14="False" Typography.StylisticSet15="False" Typography.StylisticSet16="False" Typography.StylisticSet17="False" Typography.StylisticSet18="False" Typography.StylisticSet19="False" Typography.StylisticSet20="False" Typography.Fraction="Normal" Typography.SlashedZero="False" Typography.MathematicalGreek="False" Typography.EastAsianExpertForms="False" Typography.Variants="Normal" Typography.Capitals="Normal" Typography.NumeralStyle="Normal" Typography.NumeralAlignment="Normal" Typography.EastAsianWidths="Normal" Typography.EastAsianLanguage="Normal" Typography.StandardSwashes="0" Typography.ContextualSwashes="0" Typography.StylisticAlternates="0"><Paragraph><Run>test</Run></Paragraph></Section>

请帮忙!!有什么想法吗?

最佳答案

XamlToHtml 需要 FlowDocument RichTextBox 给你一个 Section .该部分完全有效,包含您需要的文本,但 XamlToHtml 不会处理任何内容,除了完整的 FlowDocument。 .

将 Section 包裹在 <FlowDocument> 中元素,你应该可以开始了。当然,您必须调整 namespace (xmlns),因此我建议您将其作为 XmlDocument 进行操作。而不是文本。

关于c# - XAML 到 HTML 的转换 - WPF RichTextBox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2609694/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com