如何在 Windows 8 Metro 风格的 xaml C# 应用程序中从用户控件导航到页面。
更新: 实际上这个用户控件在另一个用户控件中。下面的代码在用户控件中使用时工作正常,但在嵌套的用户控件中它不起作用。
这是我当前无法运行的代码。
var cntnt = Window.Current.Content;
var frame = cntnt as Frame;
if (frame != null)
{
frame.Navigate(typeof(MyPage1), null);
}
Window.Current.Activate();
它不会导航到 MyPage1 ,但也不异常(exception)。
谢谢
最佳答案
您不应将 null 作为参数传递。试着打电话
frame.Navigate(typeof(MyPage1));
关于c# - Windows 8 Metro 导航问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10970948/