I'd like to make an application, where I can click a button and a new window appears, where new options/buttons are available. I already managed to create a new window win2 after clicking the button:
private void button1_Click(object sender, RoutedEventArgs e)
{
var win2 = new Window();
win2.Show();
this.Close();
}
Now how do I edit the new window. Let's say I want to make new buttons (named: blue, green....), where the user can chose a color for the background.
When you want to create a new Window, you cannot use the Window class directly because it acts as a template.
To add a new Window to your project:
Right Click on your Project --> Add --> New Element --> Window. Name it as you please, I will use the default (Window1).
Now you can modify this window in the same way as you did for your original window. Add any UI elements you like and code them to your desire.
To show the new window:
Window1 secondWindow = new Window1();
secondWindow.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