2016-04-04 79 views
0

WinForms ve WPF'de giriş birlikte çalışmasında sorun yaşıyorum.Başka bir pencereyi gösteren WPF UserControl ile WinForms

Win/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'ın ben DisplayWindow üzerinde metin kutusuna hiçbir şey giremezsiniz yeni DisplayWindow yaratır.

cevap

1

this deneyin:

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); 
}