PackageCatalog PackageCatalog PackageCatalog PackageCatalog Class

Definition

Provides access to app packages on the device.

public : sealed class PackageCatalog : IPackageCatalog, IPackageCatalog2
public sealed class PackageCatalog : IPackageCatalog, IPackageCatalog2
Public NotInheritable Class PackageCatalog Implements IPackageCatalog, IPackageCatalog2
// This class does not provide a public constructor.
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 )
Windows.ApplicationModel.PackageCatalog.addOptionalPackageAsync(optionalPackageFamilyName).done( /* Your success and error handlers */ );
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
var packageCatalog = Windows.ApplicationModel.PackageCatalog.openForCurrentPackage();
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
var packageCatalog = Windows.ApplicationModel.PackageCatalog.openForCurrentUser();
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) RemoveOptionalPackagesAsync(IIterable) RemoveOptionalPackagesAsync(IIterable) RemoveOptionalPackagesAsync(IIterable)

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 )
Windows.ApplicationModel.PackageCatalog.removeOptionalPackagesAsync(optionalPackageFamilyNames).done( /* Your success and error handlers */ );
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 Fall Creators Update (introduced v10.0.16299.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 TypedEventHandler PackageContentGroupStaging( Of ( Of PackageCatalog ), ( Of PackageContentGroupStagingEventArgs ))
function onPackageContentGroupStaging(eventArgs){/* Your code */}


packageCatalog.addEventListener("packageContentGroupStaging", onPackageContentGroupStaging);
packageCatalog.removeEventListener("packageContentGroupStaging", onPackageContentGroupStaging);
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 app package is installing.

public : event TypedEventHandler PackageInstalling<PackageCatalog, PackageInstallingEventArgs>
public event TypedEventHandler PackageInstalling<PackageCatalog, PackageInstallingEventArgs>
Public Event TypedEventHandler PackageInstalling( Of ( Of PackageCatalog ), ( Of PackageInstallingEventArgs ))
function onPackageInstalling(eventArgs){/* Your code */}


packageCatalog.addEventListener("packageInstalling", onPackageInstalling);
packageCatalog.removeEventListener("packageInstalling", onPackageInstalling);

Remarks

Apps only receive package events for itself or its related packages such as optional packages.

PackageStaging PackageStaging PackageStaging PackageStaging

Indicates that an app package is staging.

public : event TypedEventHandler PackageStaging<PackageCatalog, PackageStagingEventArgs>
public event TypedEventHandler PackageStaging<PackageCatalog, PackageStagingEventArgs>
Public Event TypedEventHandler PackageStaging( Of ( Of PackageCatalog ), ( Of PackageStagingEventArgs ))
function onPackageStaging(eventArgs){/* Your code */}


packageCatalog.addEventListener("packageStaging", onPackageStaging);
packageCatalog.removeEventListener("packageStaging", onPackageStaging);

Remarks

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

Apps only receive package events for itself or its related packages such as optional packages.

PackageStatusChanged PackageStatusChanged PackageStatusChanged PackageStatusChanged

Indicates that an app package has been removed or updated

public : event TypedEventHandler PackageStatusChanged<PackageCatalog, PackageStatusChangedEventArgs>
public event TypedEventHandler PackageStatusChanged<PackageCatalog, PackageStatusChangedEventArgs>
Public Event TypedEventHandler PackageStatusChanged( Of ( Of PackageCatalog ), ( Of PackageStatusChangedEventArgs ))
function onPackageStatusChanged(eventArgs){/* Your code */}


packageCatalog.addEventListener("packageStatusChanged", onPackageStatusChanged);
packageCatalog.removeEventListener("packageStatusChanged", onPackageStatusChanged);

Remarks

Apps only receive package events for itself or its related packages such as optional packages.

PackageUninstalling PackageUninstalling PackageUninstalling PackageUninstalling

Indicates that an app package is uninstalling.

public : event TypedEventHandler PackageUninstalling<PackageCatalog, PackageUninstallingEventArgs>
public event TypedEventHandler PackageUninstalling<PackageCatalog, PackageUninstallingEventArgs>
Public Event TypedEventHandler PackageUninstalling( Of ( Of PackageCatalog ), ( Of PackageUninstallingEventArgs ))
function onPackageUninstalling(eventArgs){/* Your code */}


packageCatalog.addEventListener("packageUninstalling", onPackageUninstalling);
packageCatalog.removeEventListener("packageUninstalling", onPackageUninstalling);

Remarks

Apps only receive package events for itself or its related packages such as optional packages.

PackageUpdating PackageUpdating PackageUpdating PackageUpdating

Indicates that an app package is being updated.

public : event TypedEventHandler PackageUpdating<PackageCatalog, PackageUpdatingEventArgs>
public event TypedEventHandler PackageUpdating<PackageCatalog, PackageUpdatingEventArgs>
Public Event TypedEventHandler PackageUpdating( Of ( Of PackageCatalog ), ( Of PackageUpdatingEventArgs ))
function onPackageUpdating(eventArgs){/* Your code */}


packageCatalog.addEventListener("packageUpdating", onPackageUpdating);
packageCatalog.removeEventListener("packageUpdating", onPackageUpdating);

Remarks

Apps only receive package events for itself or its related packages such as optional packages.