How to show UserControl(WPF) in a form project with not use ElementHost?
-
I know how to show a UserControl(WPF) by ElementHost in a form. like this:
private ElementHost m_elementHost;
private UserControl1 m_uc;private void button1_Click(object sender, EventArgs e)
{
m_elementHost.Child = m_uc;
}but I want to do show UserControl1 not use ElementHost, like this:
private void button1_Click(object sender, EventArgs e)
{
UserControl1 uc = new UserControl1();uc.Show();
}
-
I know how to show a UserControl(WPF) by ElementHost in a form. like this:
private ElementHost m_elementHost;
private UserControl1 m_uc;private void button1_Click(object sender, EventArgs e)
{
m_elementHost.Child = m_uc;
}but I want to do show UserControl1 not use ElementHost, like this:
private void button1_Click(object sender, EventArgs e)
{
UserControl1 uc = new UserControl1();uc.Show();
}
If you're asking how to show a WPF UserControl in a Windows Forms app without using ElementHost, you can't. ElementHost is required.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave Kreskowiak -
I know how to show a UserControl(WPF) by ElementHost in a form. like this:
private ElementHost m_elementHost;
private UserControl1 m_uc;private void button1_Click(object sender, EventArgs e)
{
m_elementHost.Child = m_uc;
}but I want to do show UserControl1 not use ElementHost, like this:
private void button1_Click(object sender, EventArgs e)
{
UserControl1 uc = new UserControl1();uc.Show();
}
Stick the user control in a WPF Window; then you can "show" it. Hide the window's "chrome" if that's a problem. Same result.
The Master said, 'Am I indeed possessed of knowledge? I am not knowing. But if a mean person, who appears quite empty-like, ask anything of me, I set it forth from one end to the other, and exhaust it.' ― Confucian Analects
-
If you're asking how to show a WPF UserControl in a Windows Forms app without using ElementHost, you can't. ElementHost is required.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave Kreskowiakthanks
-
Stick the user control in a WPF Window; then you can "show" it. Hide the window's "chrome" if that's a problem. Same result.
The Master said, 'Am I indeed possessed of knowledge? I am not knowing. But if a mean person, who appears quite empty-like, ask anything of me, I set it forth from one end to the other, and exhaust it.' ― Confucian Analects
Thank you.