Launcher
Starts the default app associated with the specified file or URI.
Learn more
LaunchUriAsync
The Launcher class provides methods to launch URIs, files, and protocols. The most common use case is to open a URI in the default web browser.
public async void ButtonWebsite_Click(object sender, RoutedEventArgs e){ // Open the website in the default browser await Launcher.LaunchUriAsync(new Uri("https://owndev.dev"));}Launch files
To open a file with the registered handler you can use Launcher.LaunchFileAsync and pass a StorageFile instance:
public async Task OpenDocumentAsync(StorageFile file){ var success = await Launcher.LaunchFileAsync(file);
if (!success) { // Provide feedback or fall back to an in-app viewer }}Customize launch options
Use LauncherOptions to control display mode, fallback URIs, or required package family names:
public async Task OpenSettingsAsync(){ var options = new LauncherOptions { DisplayApplicationPicker = false, TreatAsUntrusted = false, };
await Launcher.LaunchUriAsync(new Uri("ms-settings:appsfeatures"), options);}Troubleshooting
- Always check the boolean result of the launch call so you can surface an error or guidance to the user if no handler is registered.
- Use
Launcher.QueryUriSupportAsyncto test whether a URI protocol is supported before exposing related UI. - When launching files generated by your app, flush data to disk and close file handles before calling the launcher to avoid sharing violations.