PackageCatalog.AddOptionalPackageAsync(String) Method

Definition

Adds an optional package to the package catalog.

public:
 virtual IAsyncOperation<PackageCatalogAddOptionalPackageResult ^> ^ AddOptionalPackageAsync(Platform::String ^ optionalPackageFamilyName) = AddOptionalPackageAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<PackageCatalogAddOptionalPackageResult> AddOptionalPackageAsync(winrt::hstring const& optionalPackageFamilyName);
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<PackageCatalogAddOptionalPackageResult> AddOptionalPackageAsync(string optionalPackageFamilyName);
function addOptionalPackageAsync(optionalPackageFamilyName)
Public Function AddOptionalPackageAsync (optionalPackageFamilyName As String) As IAsyncOperation(Of PackageCatalogAddOptionalPackageResult)

Parameters

optionalPackageFamilyName
String

The package family of the optional package to add to the catalog.

Returns

IAsyncOperation<PackageCatalogAddOptionalPackageResult>

The result of starting the asynchronous operation to add the package.

Attributes

Windows requirements

Device family
Windows 10 Creators Update (introduced in 10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v4.0)

Examples

The example below installs an optional app package based on its app package family name.

var packageCatalog = PackageCatalog.OpenForCurrentPackage();
string familyName = "<Your app package family name>";
Package installedPackage = await packageCatalog.AddOptionalPackageAsync(familyName);

Remarks

This method only works for optional packages in a related set.

Applies to