Package​Catalog Package​Catalog Package​Catalog Package​Catalog Class

Definition

Some information relates to pre-released product which may be substantially modified before it’s commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Prerelease APIs are identified by a Prerelease label.

[Contains prerelease APIs.]
Provides access to app packages on the device.

public : sealed class PackageCatalog : IPackageCatalog, IPackageCatalog2public sealed class PackageCatalog : IPackageCatalog, IPackageCatalog2Public NotInheritable Class PackageCatalog Implements IPackageCatalog, IPackageCatalog2// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Methods

AddOptionalPackageAsync(String) AddOptionalPackageAsync(String) AddOptionalPackageAsync(String) AddOptionalPackageAsync(String)

Adds an optional package to the package catalog.

public : IAsyncOperation<PackageCatalogAddOptionalPackageResult> AddOptionalPackageAsync(PlatForm::String optionalPackageFamilyName)public IAsyncOperation<PackageCatalogAddOptionalPackageResult> AddOptionalPackageAsync(String optionalPackageFamilyName)Public Function AddOptionalPackageAsync(optionalPackageFamilyName As String) As IAsyncOperation( Of PackageCatalogAddOptionalPackageResult )// You can use this method in JavaScript.
Parameters
optionalPackageFamilyName
PlatForm::String String String String

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

Returns
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

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.

OpenForCurrentPackage() OpenForCurrentPackage() OpenForCurrentPackage() OpenForCurrentPackage()

Opens the catalog of packages for the main package.

public : static PackageCatalog OpenForCurrentPackage()public static PackageCatalog OpenForCurrentPackage()Public Static Function OpenForCurrentPackage() As PackageCatalog// You can use this method in JavaScript.
Returns

The package catalog for the main package.

Remarks

Use Package.Dependencies to get the list of optional packages.

OpenForCurrentUser() OpenForCurrentUser() OpenForCurrentUser() OpenForCurrentUser()

Opens the catalog of app packages on the device that are available to the current user.

public : static PackageCatalog OpenForCurrentUser()public static PackageCatalog OpenForCurrentUser()Public Static Function OpenForCurrentUser() As PackageCatalog// You can use this method in JavaScript.
Returns

The catalog of packages for the current user.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)
Capabilities
packageQuery

RemoveOptionalPackagesAsync(IIterable<String>) RemoveOptionalPackagesAsync(IIterable<String>) RemoveOptionalPackagesAsync(IIterable<String>) RemoveOptionalPackagesAsync(IIterable<String>)

Prerelease. Removes installed optional app packages from the user account.

public : IAsyncOperation<PackageCatalogRemoveOptionalPackagesResult> RemoveOptionalPackagesAsync(IIterable<PlatForm::String> optionalPackageFamilyNames)public IAsyncOperation<PackageCatalogRemoveOptionalPackagesResult> RemoveOptionalPackagesAsync(IEnumerable<String> optionalPackageFamilyNames)Public Function RemoveOptionalPackagesAsync(optionalPackageFamilyNames As IEnumerable<String>) As IAsyncOperation( Of PackageCatalogRemoveOptionalPackagesResult )// You can use this method in JavaScript.
Parameters
optionalPackageFamilyNames
IIterable<PlatForm::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>

A list of optional package family name strings.

Returns
Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.16225.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

Examples

This sample demonstrates removing all of the optional packages from a main app package.

public async void RemoveOptionalPackages() 
{ 
    // Create a list of the optional package family names
    List<string> optionalPackageList = new List<string>(); 
    foreach (var package in Windows.ApplicationModel.Package.Current.Dependencies) 
    { 
        if (package.IsOptional) 
        { 
            optionalPackageList.Add(package.Id.FamilyName); 
        } 
    } 

    // Remove the optional packages from the list    
    PackageCatalog catalog = Windows.ApplicationModel.PackageCatalog.OpenForCurrentPackage(); 
    var removalResult = await catalog.RemoveOptionalPackagesAsync(optionalPackageList); 
    if (removalResult.ExtendedError != null) 
    { 
        throw removalResult.ExtendedError; 
    } 
}

Remarks

A package family name can be found in the FamilyName property of the PackageId.

Events

PackageContentGroupStaging PackageContentGroupStaging PackageContentGroupStaging PackageContentGroupStaging

The event that is fired when a package content group starts staging.

public : event TypedEventHandler PackageContentGroupStaging<PackageCatalog,  PackageContentGroupStagingEventArgs>public event TypedEventHandler PackageContentGroupStaging<PackageCatalog,  PackageContentGroupStagingEventArgs>Public Event PackageContentGroupStaging<PackageCatalog,  PackageContentGroupStagingEventArgs>// You can use this event in JavaScript.
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

PackageInstalling PackageInstalling PackageInstalling PackageInstalling

Indicates that an optional app package is installing.

public : event TypedEventHandler PackageInstalling<PackageCatalog,  PackageInstallingEventArgs>public event TypedEventHandler PackageInstalling<PackageCatalog,  PackageInstallingEventArgs>Public Event PackageInstalling<PackageCatalog,  PackageInstallingEventArgs>// You can use this event in JavaScript.

Remarks

Apps only receive package events for their optional packages.

PackageStaging PackageStaging PackageStaging PackageStaging

Indicates that an optional app package is staging.

public : event TypedEventHandler PackageStaging<PackageCatalog,  PackageStagingEventArgs>public event TypedEventHandler PackageStaging<PackageCatalog,  PackageStagingEventArgs>Public Event PackageStaging<PackageCatalog,  PackageStagingEventArgs>// You can use this event in JavaScript.

Remarks

An app package is staged when it is added to the device but is not yet registered.

Apps only receive package events for their optional packages.

PackageStatusChanged PackageStatusChanged PackageStatusChanged PackageStatusChanged

Indicates that an optional package has been removed or updated

public : event TypedEventHandler PackageStatusChanged<PackageCatalog,  PackageStatusChangedEventArgs>public event TypedEventHandler PackageStatusChanged<PackageCatalog,  PackageStatusChangedEventArgs>Public Event PackageStatusChanged<PackageCatalog,  PackageStatusChangedEventArgs>// You can use this event in JavaScript.

Remarks

Apps only receive package events for their optional packages.

PackageUninstalling PackageUninstalling PackageUninstalling PackageUninstalling

Indicates that an optional app package is uninstalling.

public : event TypedEventHandler PackageUninstalling<PackageCatalog,  PackageUninstallingEventArgs>public event TypedEventHandler PackageUninstalling<PackageCatalog,  PackageUninstallingEventArgs>Public Event PackageUninstalling<PackageCatalog,  PackageUninstallingEventArgs>// You can use this event in JavaScript.

Remarks

Apps only receive package events for their optional packages.

PackageUpdating PackageUpdating PackageUpdating PackageUpdating

Indicates that an optional app package is being updated.

public : event TypedEventHandler PackageUpdating<PackageCatalog,  PackageUpdatingEventArgs>public event TypedEventHandler PackageUpdating<PackageCatalog,  PackageUpdatingEventArgs>Public Event PackageUpdating<PackageCatalog,  PackageUpdatingEventArgs>// You can use this event in JavaScript.

Remarks

Apps only receive package events for their optional packages.