我要实现在.cs中动态添加实现<RichTextBox x:Name="XAMLRichBox" SpellCheck.IsEnabled="True" MinHeight="100">
    <FlowDocument>
        <Paragraph>
            USB Charge+ functions to charge your mobile phones or digital audio players while your Eee PC is sleeping, hibernating or shut down. Two modes are available for you to choose from, <TextBlock Foreground="Blue">Adapter Mode</TextBlock>, or <TextBlock Foreground="Blue">Adapter + Battery Mode</TextBlock>.
        </Paragraph>
        <Paragraph>
            Notices:
        </Paragraph>
        <Paragraph>
            aaa
            <LineBreak></LineBreak>
           bbb <TextBlock Foreground="Blue">ccc</TextBlock>hhh            
<LineBreak></LineBreak>
            dddd
            <LineBreak></LineBreak>
              </FlowDocument>
</RichTextBox>
Run run1 = new Run("tttttt");
Run run2 = new Run(" wwww:");
Run run3 = new Run("wweeeeee.");
LineBreak lineB1 = new LineBreak();
FlowDocument fd = new FlowDocument();
 fd.Blocks.Add(new Paragraph(run1));
 TextBlock tx1 = new TextBlock();
 tx1.Text = "Adapter mode+";
 tx1.Foreground = "Red";
 fd.Blocks.Add(new Paragraph(run2));
 fd.Blocks.Add(new Paragraph(run3));
我怎么把textblock动态的添加到paragraph中。具体是如何通过代码来实现上面的一个richtextbox,谢谢

解决方案 »

  1.   

    没看明白你的意思。上面的xaml也是错误的。<RichTextBox x:Name="XAMLRichBox" SpellCheck.IsEnabled="True" MinHeight="100">
      <FlowDocument>
      <Paragraph>
      USB Charge+ functions to charge your mobile phones or digital audio players while your Eee PC is sleeping, hibernating or shut down. Two modes are available for you to choose from, <TextBlock Foreground="Blue">Adapter Mode</TextBlock>, or <TextBlock Foreground="Blue">Adapter + Battery Mode</TextBlock>.
      </Paragraph>
      <Paragraph>
      Notices:
      </Paragraph>
      <Paragraph>
      aaa
      <LineBreak></LineBreak>
      bbb <TextBlock Foreground="Blue">ccc</TextBlock>hhh   
    <LineBreak></LineBreak>
      dddd
      <LineBreak></LineBreak>
    </Paragraph>
      </FlowDocument>
    </RichTextBox>