2010-04-09 215 views
2

我有問題,我有一個WPF RichTextBox,我解壓縮它的XAML代碼並將其保存到一個txt文件。當我複製粘貼生成XAMLtoHTML轉換器像這樣http://blogs.msdn.com/wpfsdk/archive/2006/05/25/606317.aspx,一些錯誤必須發生,因爲我總是得到一個空白的結果!XAML到HTML轉換 - WPF RichTextBox

如果我寫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>

pleaseee幫助!有任何想法嗎?

回答

9

XamlToHtml期望FlowDocument和RichTextBox給你一個Section。該部分是完全有效的,包含您需要的文本,但XamlToHtml將不會處理任何內容,除非完整FlowDocument

將部分包裹在<FlowDocument>元素中,你應該很好。您當然必須調整名稱空間(xmlns),所以我建議您將其作爲XmlDocument而不是文本進行操作。

+0

這非常有幫助,非常感謝你!它完全解決了我在追加開頭和結尾處的問題 – Erika 2010-05-13 21:56:06