简体   繁体   中英

how to get back to the tile page(start screen) after launching the ConnectionSettings Task in WP8

I am trying to launch the Connection settings task from the secondary tile. For that I am creating a tile and giving the uri as like

"ShellTile.Create(new Uri("/LaunchSettings.xaml", UriKind.Relative), standardTileData);".

In LaunchSettings.Xaml launching Bluetooth setting using URI Scheme. like

"await Launcher.LaunchUriAsync(new Uri("ms-settings-Bluetooth:"));"

But once settings launched if I click back button, its coming to the LaunchSettings.xaml. Not returning to the Start screen. How to achieve that?

Please advice.

Just write Application.Current.Terminate(); after the Launcher.

launches the Uri while closing your app.

You need to exit the application in the OnNavigatedToEvent , so add the following override to your LaunchSettings.xaml.cs file:

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    if (e.NavigationMode == NavigationMode.Back)
        Application.Current.Terminate();

    base.OnNavigatedTo(e);
}

Note that this will not trigger for example the Application_Closing event (see this link: http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.application.terminate(v=vs.105).aspx ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM