本文介绍了XAML到HTML的转换-WPF RichTextBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到的问题是我拥有WPF RichTextBox,并且正在提取其XAML代码并将其保存到txt文件中.当我复制时,将生成的XAML代码粘贴到这样的XAMLtoHTML转换器中http://blogs.msdn.com/wpfsdk/archive/2006/05/25/606317.aspx ,由于我总是得到空白结果,所以必须发生一些错误!

I have the problem where i have a WPF RichTextBox, and i'm extracting its XAML code and saving it to a txt file. When i copy paste the XAML code generated to a XAMLtoHTML converter like this http://blogs.msdn.com/wpfsdk/archive/2006/05/25/606317.aspx , some error must be occuring as i'm always getting a blank result!

如果我在RichTextBox中编写 test ,则会收到以下XAML:

If i write test in the RichTextBox i get the following XAML:

<部分xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xml:space ="preserve" TextAlignment ="Left" LineHeight ="Auto" IsHyphenationEnabled ="False"xml:lang =" zh-cn"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 =常规" Typography.EastAsianWidths =常规" Typography.EastAsianLanguage =常规" Typography.StandardSwashes ="0" Typography.ContextualSwashes ="0" Typography.StylisticAlternates ="0">< Paragraph>< Run> test</Run></Paragraph></Section>

请帮助!!有任何想法吗?

pleaseee help!! Any Ideas?

推荐答案

XamlToHtml期望 FlowDocument ,RichTextBox为您提供 Section .该节是包含您所需文本的完全有效的文件,但是XamlToHtml除了完整的 FlowDocument 之外不会处理任何其他内容.

XamlToHtml expects a FlowDocument and RichTextBox is giving you a Section. The Section is a perfectly valid containing the text you need, but XamlToHtml won't process anything except a full FlowDocument.

将节包装在< FlowDocument> 元素中,您应该会很好.当然,您必须调整名称空间(xmlns),所以我建议您将其作为 XmlDocument 而不是文本进行操作.

Wrap the Section in a <FlowDocument> element and you should be good to go. You'll have to adjust the namespace (xmlns) of course, so I suggest you manipulate it as an XmlDocument instead of as text.

这篇关于XAML到HTML的转换-WPF RichTextBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 02:18