私の Windows ストア アプリでは、Microsoft のガイドラインに従って、終了後にアプリを再開しました ( http://goo.gl/oZ7BG )。それはすべて機能しますが、アプリが終了した後、ログインページ(アプリの最初のページ)にジャンプして、アプリのメニューページに直接移動したいと思います。Dropbox アプリとまったく同じです。私は App.xaml.cs とこのメソッドに取り組む必要があることを知っています:
protected async override void OnLaunched(LaunchActivatedEventArgs args)
{
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
bool appTerminated = false;
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
marketingHP.Common.SuspensionManager.RegisterFrame(rootFrame, "appFrame");
if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
await marketingHP.Common.SuspensionManager.RestoreAsync();
appTerminated = true;
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
if (appTerminated)
rootFrame.Navigate(typeof(HomePage), args.Arguments);
else if (!rootFrame.Navigate(typeof(LoginPage), args.Arguments))
{
throw new Exception("Failed to create initial page");
}
}
// Ensure the current window is active
Window.Current.Activate();
}
アプリが以前に終了したことをどのように理解できますか? bool appTerminated を追加しましたが、サスペンドに対してのみ機能することに注意してください...