要解决“Application.Current.
this.InitializeComponent();
// 注册页面
RegisterPage();
Frame rootFrame = Window.Current.Content as Frame;
// 导航到页面
rootFrame.Navigate(typeof(PageName));
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
Frame rootFrame = Window.Current.Content as Frame;
// 检查是否已存在根框架
if (rootFrame == null)
{
// 创建根框架
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
// TODO: 从之前挂起的应用程序加载状态
}
// 将根框架放在当前窗口中
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// 导航到页面
rootFrame.Navigate(typeof(PageName), e.Arguments);
}
// 确保当前窗口处于活动状态
Window.Current.Activate();
}
var frame = (Frame)Window.Current.Content;
frame.Navigate(typeof(PageName));
这些方法中的任何一个都可能解决“Application.Current.