2010-04-09 3 views
2

WPF RichTextBox가있는 곳에서 XAML 코드를 추출하여 txt 파일에 저장하고 있습니다. 이 http://blogs.msdn.com/wpfsdk/archive/2006/05/25/606317.aspx과 같은 XAMLtoHTML 변환기에 생성 된 XAML 코드를 복사하여 복사하면 항상 빈 결과가 표시되므로 일부 오류가 발생해야합니다.XAML에서 HTML 로의 변환 - WPF RichTextBox

나는 다음과 같은 XAML 얻을를 RichTextBox에 test을 작성하는 경우 :

<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