我对C#和WPF架构非常陌生。我正在尝试使用简单的页面导航创建应用程序。我已将我的MainWindow从Window更改为NavigationWindow。我也把下面的代码在MainWindow.xaml.csWPF导航C#
public void View(string newView)
{
Uri View = new Uri(newView, UriKind.RelativeOrAbsolute);
this.Navigate(View);
}
我打电话从原始出处按钮这个方法:
private void Button_Click(object sender, RoutedEventArgs e)
{
string View;
View = "Pages/UserAdd.xaml";
MainWindow mainWindow = new MainWindow();
mainWindow.View(View);
}
然而,当我按一下按钮没有任何反应。我已经使用了BreakPoints,并且方法肯定是被调用的。
在此先感谢。
如果你是新的WPF,我建议阅读有关MVVM模式https://mvvmlight.codeplex.com/第一。大多数wpf应用程序遵循这种模式 –
有一个非常漂亮的博客https://rachel53461.wordpress.com/2011/12/18/navigation-with-mvvm-2/您可以参考 – Vikram