我在WinForms和WPF中遇到输入互操作问题。
的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();
}
}
当userControl创建新的DisplayWindow时,我无法在DisplayWindow的文本框中输入任何内容。
答案 0 :(得分: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);
}