LauncherOptions LauncherOptions LauncherOptions LauncherOptions LauncherOptions Class

Definition

Specifies the options used to launch the default app for a file or URI.

public : sealed class LauncherOptions : ILauncherOptions, ILauncherOptions2, ILauncherOptions3, ILauncherOptions4, ILauncherViewOptions
struct winrt::Windows::System::LauncherOptions : ILauncherOptions, ILauncherOptions2, ILauncherOptions3, ILauncherOptions4, ILauncherViewOptions
public sealed class LauncherOptions : ILauncherOptions, ILauncherOptions2, ILauncherOptions3, ILauncherOptions4, ILauncherViewOptions
Public NotInheritable Class LauncherOptions Implements ILauncherOptions, ILauncherOptions2, ILauncherOptions3, ILauncherOptions4, ILauncherViewOptions
var launcherOptions = new launcherOptions();
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

Call the Launcher.LaunchFileAsync(IStorageFile, LauncherOptions) | launchFileAsync(IStorageFile, LauncherOptions) method with LauncherOptions.DisplayApplicationPicker | displayApplicationPicker set to true to launch the app that the user selects for the file from the Open With dialog box.


// Path to the file in the app package to launch
var imageFile = "images\\test.png";

// Get the image file from the package's image directory
Windows.ApplicationModel.Package.current.installedLocation.getFileAsync(imageFile).then(
  function (file) {
    // Set the show picker option
    var options = new Windows.System.LauncherOptions();
    options.displayApplicationPicker = true;

    // Launch the retrieved file using the selected app
    Windows.System.Launcher.launchFileAsync(file, options).then(
      function (success) {
        if (success) {
            // File launched
        } else {
            // File launch failed
        }
      });
  });
async void DefaultLaunch()
{
   // Path to the file in the app package to launch
   string imageFile = @"images\test.png";

   var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);

   if (file != null)
   {
      // Set the option to show the picker
      var options = new Windows.System.LauncherOptions();
      options.DisplayApplicationPicker = true;

      // Launch the retrieved file
      bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
      if (success)
      {
         // File launched
      }
      else
      {
         // File launch failed
      }
   }
   else
   {
      // Could not find file
   }
}
async Sub DefaultLaunch()

   ' Path to the file in the app package to launch
   Dim imageFile = "images\test.png"

   Dim file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile)

   If file IsNot Nothing Then
      ' Set the option to show the picker
      Dim options = Windows.System.LauncherOptions()
      options.DisplayApplicationPicker = True

      ' Launch the retrieved file
      Dim success = await Windows.System.Launcher.LaunchFileAsync(file, options)

      If success Then
         ' File launched
      Else
         ' File launch failed
      End If
   Else
      ' Could not find file
   End If
End Sub
void MainPage::DefaultLaunch()
{
   auto installFolder = Windows::ApplicationModel::Package::Current->InstalledLocation;

   concurrency::task<Windows::Storage::StorageFile^> getFileOperation(installFolder->GetFileAsync("images\\test.png"));
   getFileOperation.then([](Windows::Storage::StorageFile^ file)
   {
      if (file != nullptr)
      {
         // Set the option to show the picker
         auto launchOptions = ref new Windows::System::LauncherOptions();
         launchOptions->DisplayApplicationPicker = true;

         // Launch the retrieved file
         concurrency::task<bool> launchFileOperation(Windows::System::Launcher::LaunchFileAsync(file, launchOptions));
         launchFileOperation.then([](bool success)
         {
            if (success)
            {
               // File launched
            }
            else
            {
               // File launch failed
            }
         });
      }
      else
      {
         // Could not find file
      }
   });
}

Constructors

LauncherOptions() LauncherOptions() LauncherOptions() LauncherOptions() LauncherOptions()

Creates and initializes a new instance of the launcher options object.

Properties

ContentType ContentType ContentType ContentType ContentType

Gets or sets the content type that is associated with a URI that represents a file on the network.

DesiredRemainingView DesiredRemainingView DesiredRemainingView DesiredRemainingView DesiredRemainingView

Launch a target app and have the currently running source app remain on the screen by sharing the space equally with the target app or by taking up more or less space than the target app.

DisplayApplicationPicker DisplayApplicationPicker DisplayApplicationPicker DisplayApplicationPicker DisplayApplicationPicker

Gets or sets a value that indicates whether to display the Open With dialog whenever the association launching API is called.

FallbackUri FallbackUri FallbackUri FallbackUri FallbackUri

Gets or sets a value that represents a URI that the user should be taken to in the browser if no app exists to handle the file type or URI.

IgnoreAppUriHandlers IgnoreAppUriHandlers IgnoreAppUriHandlers IgnoreAppUriHandlers IgnoreAppUriHandlers

Indicates whether to ignore handlers that can handle http(s) schemes (such as browsers). Instead, launch will fall back to the default browser.

LimitPickerToCurrentAppAndAppUriHandlers LimitPickerToCurrentAppAndAppUriHandlers LimitPickerToCurrentAppAndAppUriHandlers LimitPickerToCurrentAppAndAppUriHandlers LimitPickerToCurrentAppAndAppUriHandlers

Gets or sets whether to limit the picker for the launcher to the current app and its associated URI handlers.

NeighboringFilesQuery NeighboringFilesQuery NeighboringFilesQuery NeighboringFilesQuery NeighboringFilesQuery

Enables an app to access files that are related to the file used to activate the app.

PreferredApplicationDisplayName PreferredApplicationDisplayName PreferredApplicationDisplayName PreferredApplicationDisplayName PreferredApplicationDisplayName

Gets or sets a value that represents the display name of the app in the store that the user should install if no app exists to handle the file type or URI.

PreferredApplicationPackageFamilyName PreferredApplicationPackageFamilyName PreferredApplicationPackageFamilyName PreferredApplicationPackageFamilyName PreferredApplicationPackageFamilyName

Gets or sets a value that represents the package family name of the app in the Store that the user should install if no app exists to handle the file type or URI.

TargetApplicationPackageFamilyName TargetApplicationPackageFamilyName TargetApplicationPackageFamilyName TargetApplicationPackageFamilyName TargetApplicationPackageFamilyName

The package family name of the target package that should be used to launch a file or URI. This property is optional.

TreatAsUntrusted TreatAsUntrusted TreatAsUntrusted TreatAsUntrusted TreatAsUntrusted

Gets or sets a value that indicates whether the system should display a warning that the file or URI is potentially unsafe when starting the app associated with a file or URI.

UI UI UI UI UI

Gets the user interface (UI) options when starting a default app.

See Also