I am creating a Kinect application and want to open a new window called 'Help' from the 'MainWindow.xaml.cs' file.
I tried using the following code:
// The commented code is what I have tried.
public static void ThreadProc()
{
// Window Help = new Window();
//Application.Run(new Window(Help);
Application.Run(new Form());
}
private void button1_Click(object sender, EventArgs e)
{
System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadProc));
t.Start();
}
Showing a window just requires a call to its Show
method.
However, keeping an application running requires a call to Application.Run
. If you pass this method a form, it'll call Show
for you.
However, if you already have a running application, you can just do something like new MyForm().Show()
.
I strongly suspect you don't need to create a new thread and Application
for your new window. Can't you just use:
private void button1_Click(object sender, EventArgs e)
{
new Form().Show();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With