2016-04-04 67 views
0

我在WinForms和WPF中輸入互操作時遇到問題。用WPF UserControl顯示另一個窗口的WinForms

的WinForms/C#:

UserControlDLL.MyUserControl userControl = new UserControlDLL.MyUserControl(); 

public Form1() 
{ 
    InitializeComponent(); 
} 

private void button1_Click(object sender, EventArgs e) 
{ 
    userControl.ShowTextBox(); 
} 

WPF:

public partial class MyUserControl : UserControl 
{ 
    internal static DisplayWindow display; 

    public MyUserControl() 
    { 
     InitializeComponent(); 
     display = new DisplayWindow(); 
    } 
} 

當用戶控件創建新DisplayWindow我不能在DisplayWindow文本框中輸入任何內容。

回答

1

嘗試this

public Form1() 
{ 
    InitializeComponent(); 

    ElementHost host= new ElementHost(); 
    host.Size = new Size(200, 100); 
    host.Location = new Point(100,100); 

    UserControlDLL.MyUserControl edit = new UserControlDLL.MyUserControl(); 
    host.Child = edit; 

    this.Controls.Add(host); 
} 
相關問題