我正在尝试在 Flowdocument 中显示此 XAML 部分
<Section xml:space='preserve' xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'><Paragraph><Hyperlink NavigateUri='E6A88D2B.js'/></Paragraph><Paragraph /><Paragraph><Span Foreground='blue'><Run FontWeight='bold'>NOW, the</Run></Span><Span>/ˌen əʊ ˈdʌb<Run FontStyle='italic'>ə</Run>ljuː $ -oʊ-/ </Span><Run>BrE</Run><Run /><Run /><Run>AmE</Run><Run /><Run /><LineBreak /><Span><Span FontWeight='bold'><Run Foreground='blue'>(the National Organization for Women)</Run></Span> a large US organization started in 1966, which works for legal, economic, and social equality between women and men. Its first president was Betty ↑<Run>Friedan</Run>, who also helped to start it</Span><LineBreak /></Paragraph></Section>
当我在 flowdocument 标记中插入我的 XAML 代码时,它会完美地显示内容并格式化:
<FlowDocumentScrollViewer Width="400" VerticalAlignment="Bottom" Height="200" >
<FlowDocument>
<Section xml:space='preserve' xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'><Paragraph><Hyperlink NavigateUri='E6A88D2B.js'/></Paragraph><Paragraph /><Paragraph><Span Foreground='blue'><Run FontWeight='bold'>NOW, the</Run></Span><Span>/ˌen əʊ ˈdʌb<Run FontStyle='italic'>ə</Run>ljuː $ -oʊ-/ </Span><Run>BrE</Run><Run /><Run /><Run>AmE</Run><Run /><Run /><LineBreak /><Span><Span FontWeight='bold'><Run Foreground='blue'>(the National Organization for Women)</Run></Span> a large US organization started in 1966, which works for legal, economic, and social equality between women and men. Its first president was Betty ↑<Run>Friedan</Run>, who also helped to start it</Span><LineBreak /></Paragraph></Section>
</FlowDocument>
</FlowDocumentScrollViewer>
但是我想从后面的代码中以编程方式执行此操作,但它不起作用。它显示与插入的 XAML 代码完全相同的未格式化 XAML 文本
Paragraph paragraph = new Paragraph();
paragraph.Inlines.Add(new Run(myXamlCode));
Section section = new Section();
section.Blocks.Add(paragraph);
myFlowDocument.Blocks.Add(section);
显示 XAML 代码的最佳方法是什么?