如何从桌面 WPF 应用程序中的页面导航到新页面或 Window
。我尝试了以下方法调用 windows 页面,但出现错误:
Window must be the root of the tree. Cannot add Window as a child of Visual
private void btCode_Click(object sender, RoutedEventArgs e)
{
CodeView window = new CodeView(cbRe.Text, txtID.Text);
this.Content = window;
}
当我更改代码以调用新页面时,我收到类似的错误消息,指出必须从 Window
调用页面。
最佳答案
打开一个窗口的页面
myWindow w = new myWindow();
w.Show();
导航到新页面
myPage p = new myPage();
myFrameInCurrentWindow.Navigate(p);
关于c# - 从桌面 WPF 应用程序中的页面导航到新页面或窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19067266/