下面代码不行: System.Windows.Forms.RichTextBox rtb=new  System.Windows.Forms.RichTextBox();
 this.border.Child=rtb;

解决方案 »

  1.   

    这是在WPF下调用WinForms的RichTextBox的例子。原来,挺简单的,不过估计很多人不知道:
    首先,添加引用:右击References-->.NET-->System.Windows.Forms;接着,添加引用:右击References-->Browse-->C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\Framework\v3.0\WindowsFormsIntegration.dll然后,在后代代码中写上:
    System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();
    System.Windows.Forms.RichTextBox rtb = new System.Windows.Forms.RichTextBox();
    host.Child = rtb;
    this.border.Child = host;