I want to open window2.xaml from the window1.xaml window as an emergent (floating) window. In winforms that was form2.show() , how do I do it in WPF for both WPF application and WPFbrowser application? (I assume it's different for WPF application and WPFbrowser application)开发者_如何转开发
It is not much different in WPF than winforms. The method itself is still Show() for a WPF window.
Button btnClick = new Button();
btnClick.Click += btnClick_Click;
void btnClick_Click(object sender, RoutedEventArgs e)
{
window2 exampleWindow = new window2();
exampleWindow.Show();
}
You pick where you want to instantiate and show the window depending on how you want your program to operate.
Update:
In a WPF web app you have ChildWindows. If you create your own custom window which inherits ChildWindow it will call just like any other window in a WPF app. The method is once again.
exampleChildWindow.Show();
精彩评论