private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
Win1 OP= new Win1();
OP.show();
}
OP.show() is throwing an error.
It is a usercontrol form.
You say that Win1
is "It is a usercontrol form." (emphasis is mine).
If Win1
is actually of type UserControl
, the issues is that the type UserControl
doesn't define Show()
method. So it cannot be "opened" as a window.
To solve this you need to open a window and have the UC as the content for that window:
private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
Win1 OP= new Win1();
var host = new Window();
host.Content = OP;
host.Show();
}
As a side note, you can use UserControl
as StartupUri
in App.xaml and it will work since the framework recognizes that it's not a window and creates a window for it.
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