StoreContext StoreContext StoreContext StoreContext StoreContext Class

Definition

Provides members you can use to access and manage Microsoft Store-related data for the current app. For example, you can use members of this class to get Microsoft Store listing and license info for the current app, purchase the current app or products that are offered by the app, or download and install package updates for the app.

public : sealed class StoreContext : IStoreContext, IStoreContext2, IStoreContext3, IStoreContext4
struct winrt::Windows::Services::Store::StoreContext : IStoreContext, IStoreContext2, IStoreContext3, IStoreContext4
public sealed class StoreContext : IStoreContext, IStoreContext2, IStoreContext3, IStoreContext4
Public NotInheritable Class StoreContext Implements IStoreContext, IStoreContext2, IStoreContext3, IStoreContext4
// 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.Services.Store.StoreContract (introduced v1)

Remarks

Note

This class and the rest of the Windows.Services.Store namespace was introduced in Windows 10, version 1607. This class can only be used in projects that target Windows 10 Anniversary Edition (10.0; Build 14393) or a later release in Visual Studio. If your project targets an earlier version of Windows 10, you must use the Windows.ApplicationModel.Store namespace instead of the Windows.Services.Store namespace. For more information, see In-app purchases and trials.

The StoreContext class is the main entry point to the Windows.Services.Store namespace. Use members of this class to perform tasks such as getting Microsoft Store listing and license info for the current app, purchasing the current app or add-ons that are offered by the app, or downloading and installing package updates for the app. Other classes and types in this namespace represent items such as add-ons for the app, licenses for the app and its add-ons, and Microsoft Store listing info for the app.

To get a StoreContext object, use one of these static methods:

  • GetDefault: Use this method in single-user apps (that is, apps that run only in the context of the user that launched the app). This method gets a StoreContext object that you can use to access and manage Microsoft Store-related data for the user. Most Universal Windows Platform (UWP) apps are single-user apps.

    Windows.Services.Store.StoreContext context = StoreContext.GetDefault();
    
  • GetForUser: Use this method in multi-user apps. This method gets a StoreContext object that you can use to access and manage Microsoft Store-related data for a specific user. For more information about multi-user apps, see Introduction to multi-user applications.

    var users = await Windows.System.User.FindAllAsync();
    Windows.Services.Store.StoreContext context = StoreContext.GetForUser(users[0]);
    

Note

In a Windows desktop application that uses the Desktop Bridge, you must add some additional code to configure the StoreContext object before your app can use this object. For more information, see Using the StoreContext class in a desktop application that uses the Desktop Bridge.

After you have a StoreContext object, you can start calling methods to purchase an app or add-on for the current user and other tasks. For more information, see the following articles:

You can also use a StoreContext object to download and install package updates for the app. For more information, see Download and install package updates for your app.

Properties

CanSilentlyDownloadStorePackageUpdates CanSilentlyDownloadStorePackageUpdates CanSilentlyDownloadStorePackageUpdates CanSilentlyDownloadStorePackageUpdates CanSilentlyDownloadStorePackageUpdates

Gets a value that indicates whether package updates for the current app can be downloaded without displaying a notification UI to the user.

User User User User User

Gets info about the user that is associated with the current StoreContext object in a multi-user app.

Methods

AcquireStoreLicenseForOptionalPackageAsync(Package) AcquireStoreLicenseForOptionalPackageAsync(Package) AcquireStoreLicenseForOptionalPackageAsync(Package) AcquireStoreLicenseForOptionalPackageAsync(Package) AcquireStoreLicenseForOptionalPackageAsync(Package)

Acquires a license for the specified downloadable content (DLC) add-on package for the current app.

CanAcquireStoreLicenseAsync(String) CanAcquireStoreLicenseAsync(String) CanAcquireStoreLicenseAsync(String) CanAcquireStoreLicenseAsync(String) CanAcquireStoreLicenseAsync(String)

Gets a value that indicates whether a license can be acquired for the specified downloadable content (DLC) add-on of the current app for the current user.

CanAcquireStoreLicenseForOptionalPackageAsync(Package) CanAcquireStoreLicenseForOptionalPackageAsync(Package) CanAcquireStoreLicenseForOptionalPackageAsync(Package) CanAcquireStoreLicenseForOptionalPackageAsync(Package) CanAcquireStoreLicenseForOptionalPackageAsync(Package)

Gets a value that indicates whether a license can be acquired for the specified downloadable content (DLC) package of the current app for the current user.

DownloadAndInstallStorePackagesAsync(IIterable<String>) DownloadAndInstallStorePackagesAsync(IIterable<String>) DownloadAndInstallStorePackagesAsync(IIterable<String>) DownloadAndInstallStorePackagesAsync(IIterable<String>) DownloadAndInstallStorePackagesAsync(IIterable<String>)

Downloads and installs the specified downloadable content (DLC) packages for the current app from the Microsoft Store without displaying a notification UI dialog to the user.

FindStoreProductForPackageAsync(IIterable<String>, Package) FindStoreProductForPackageAsync(IIterable<String>, Package) FindStoreProductForPackageAsync(IIterable<String>, Package) FindStoreProductForPackageAsync(IIterable<String>, Package) FindStoreProductForPackageAsync(IIterable<String>, Package)

Gets Store product details for the app or add-on that is associated with the specified package.

GetAppAndOptionalStorePackageUpdatesAsync() GetAppAndOptionalStorePackageUpdatesAsync() GetAppAndOptionalStorePackageUpdatesAsync() GetAppAndOptionalStorePackageUpdatesAsync() GetAppAndOptionalStorePackageUpdatesAsync()

Gets the collection of packages for the current app that have updates available for download from the Microsoft Store, including optional packages for the app.

GetAppLicenseAsync() GetAppLicenseAsync() GetAppLicenseAsync() GetAppLicenseAsync() GetAppLicenseAsync()

Gets license info for the current app, including licenses for add-ons for the current app.

GetAssociatedStoreProductsAsync(IIterable<String>) GetAssociatedStoreProductsAsync(IIterable<String>) GetAssociatedStoreProductsAsync(IIterable<String>) GetAssociatedStoreProductsAsync(IIterable<String>) GetAssociatedStoreProductsAsync(IIterable<String>)

Gets Microsoft Store listing info for the products that can be purchased from within the current app.

GetAssociatedStoreProductsWithPagingAsync(IIterable<String>, UInt32) GetAssociatedStoreProductsWithPagingAsync(IIterable<String>, UInt32) GetAssociatedStoreProductsWithPagingAsync(IIterable<String>, UInt32) GetAssociatedStoreProductsWithPagingAsync(IIterable<String>, UInt32) GetAssociatedStoreProductsWithPagingAsync(IIterable<String>, UInt32)

Gets Microsoft Store listing info for the products that can be purchased from within the current app. This method supports paging to return the results.

GetAssociatedStoreQueueItemsAsync() GetAssociatedStoreQueueItemsAsync() GetAssociatedStoreQueueItemsAsync() GetAssociatedStoreQueueItemsAsync() GetAssociatedStoreQueueItemsAsync()

Gets info about all the new or updated packages that are in the download and installation queue for the current app.

GetConsumableBalanceRemainingAsync(String) GetConsumableBalanceRemainingAsync(String) GetConsumableBalanceRemainingAsync(String) GetConsumableBalanceRemainingAsync(String) GetConsumableBalanceRemainingAsync(String)

Gets the remaining balance for the specified consumable add-on for the current app.

GetCustomerCollectionsIdAsync(String, String) GetCustomerCollectionsIdAsync(String, String) GetCustomerCollectionsIdAsync(String, String) GetCustomerCollectionsIdAsync(String, String) GetCustomerCollectionsIdAsync(String, String)

Retrieves a Microsoft Store ID key that can be used to query for product entitlements or to consume product entitlements that are owned by the current user.

GetCustomerPurchaseIdAsync(String, String) GetCustomerPurchaseIdAsync(String, String) GetCustomerPurchaseIdAsync(String, String) GetCustomerPurchaseIdAsync(String, String) GetCustomerPurchaseIdAsync(String, String)

Retrieves a Microsoft Store ID key that can be used to grant entitlements for free products on behalf of the current user.

GetDefault() GetDefault() GetDefault() GetDefault() GetDefault()

Gets a StoreContext object that can be used to access and manage Microsoft Store-related data for the current user in the context of the current app.

GetForUser(User) GetForUser(User) GetForUser(User) GetForUser(User) GetForUser(User)

Gets a StoreContext object that can be used to access and manage Microsoft Store-related data for the specified user in the context of the current app.

GetStoreProductForCurrentAppAsync() GetStoreProductForCurrentAppAsync() GetStoreProductForCurrentAppAsync() GetStoreProductForCurrentAppAsync() GetStoreProductForCurrentAppAsync()

Gets Microsoft Store listing info for the current app and provides access to a method that you can use to purchase the app for the current user.

GetStoreProductsAsync(IIterable<String>, IIterable<String>) GetStoreProductsAsync(IIterable<String>, IIterable<String>) GetStoreProductsAsync(IIterable<String>, IIterable<String>) GetStoreProductsAsync(IIterable<String>, IIterable<String>) GetStoreProductsAsync(IIterable<String>, IIterable<String>)

Gets Microsoft Store listing info for the specified products that are associated with the current app.

GetStoreProductsAsync(IIterable<String>, IIterable<String>, StoreProductOptions) GetStoreProductsAsync(IIterable<String>, IIterable<String>, StoreProductOptions) GetStoreProductsAsync(IIterable<String>, IIterable<String>, StoreProductOptions) GetStoreProductsAsync(IIterable<String>, IIterable<String>, StoreProductOptions) GetStoreProductsAsync(IIterable<String>, IIterable<String>, StoreProductOptions)

Gets Microsoft Store listing info for the specified products that are associated with the current app, with the option to use a filter for the query.

GetStoreQueueItemsAsync(IIterable<String>) GetStoreQueueItemsAsync(IIterable<String>) GetStoreQueueItemsAsync(IIterable<String>) GetStoreQueueItemsAsync(IIterable<String>) GetStoreQueueItemsAsync(IIterable<String>)

Gets info about the specified new or updated packages that are in the download and installation queue for the current app.

GetUserCollectionAsync(IIterable<String>) GetUserCollectionAsync(IIterable<String>) GetUserCollectionAsync(IIterable<String>) GetUserCollectionAsync(IIterable<String>) GetUserCollectionAsync(IIterable<String>)

Gets Microsoft Store info for the add-ons of the current app for which the user has purchased.

GetUserCollectionWithPagingAsync(IIterable<String>, UInt32) GetUserCollectionWithPagingAsync(IIterable<String>, UInt32) GetUserCollectionWithPagingAsync(IIterable<String>, UInt32) GetUserCollectionWithPagingAsync(IIterable<String>, UInt32) GetUserCollectionWithPagingAsync(IIterable<String>, UInt32)

Gets Microsoft Store info for the add-ons of the current app for which the user has purchased. This method supports paging to return the results.

ReportConsumableFulfillmentAsync(String, UInt32, Guid) ReportConsumableFulfillmentAsync(String, UInt32, Guid) ReportConsumableFulfillmentAsync(String, UInt32, Guid) ReportConsumableFulfillmentAsync(String, UInt32, Guid) ReportConsumableFulfillmentAsync(String, UInt32, Guid)

Reports a consumable add-on for the current app as fulfilled in the Microsoft Store.

RequestDownloadAndInstallStorePackagesAsync(IIterable<String>) RequestDownloadAndInstallStorePackagesAsync(IIterable<String>) RequestDownloadAndInstallStorePackagesAsync(IIterable<String>) RequestDownloadAndInstallStorePackagesAsync(IIterable<String>) RequestDownloadAndInstallStorePackagesAsync(IIterable<String>)

Attempts to download and install the specified downloadable content (DLC) packages for the current app from the Microsoft Store. This method also displays a UI dialog that requests permission for the operation.

Important

This method must be called on the UI thread.

RequestDownloadAndInstallStorePackagesAsync(IIterable<String>, StorePackageInstallOptions) RequestDownloadAndInstallStorePackagesAsync(IIterable<String>, StorePackageInstallOptions) RequestDownloadAndInstallStorePackagesAsync(IIterable<String>, StorePackageInstallOptions) RequestDownloadAndInstallStorePackagesAsync(IIterable<String>, StorePackageInstallOptions) RequestDownloadAndInstallStorePackagesAsync(IIterable<String>, StorePackageInstallOptions)

Attempts to download and install the specified downloadable content (DLC) packages for the current app from the Microsoft Store, with the specified install options. This method also displays a UI dialog that requests permission for the operation.

Important

This method must be called on the UI thread.

RequestDownloadAndInstallStorePackageUpdatesAsync(IIterable<StorePackageUpdate>) RequestDownloadAndInstallStorePackageUpdatesAsync(IIterable<StorePackageUpdate>) RequestDownloadAndInstallStorePackageUpdatesAsync(IIterable<StorePackageUpdate>) RequestDownloadAndInstallStorePackageUpdatesAsync(IIterable<StorePackageUpdate>) RequestDownloadAndInstallStorePackageUpdatesAsync(IIterable<StorePackageUpdate>)

Attempts to download and install the specified package updates for the current app from the Microsoft Store. This method also displays a UI dialog that requests permission for the operation.

Important

This method must be called on the UI thread.

RequestDownloadStorePackageUpdatesAsync(IIterable<StorePackageUpdate>) RequestDownloadStorePackageUpdatesAsync(IIterable<StorePackageUpdate>) RequestDownloadStorePackageUpdatesAsync(IIterable<StorePackageUpdate>) RequestDownloadStorePackageUpdatesAsync(IIterable<StorePackageUpdate>) RequestDownloadStorePackageUpdatesAsync(IIterable<StorePackageUpdate>)

Attempts to download the specified package updates for the current app from the Microsoft Store. This method also displays a UI dialog that requests permission for the operation.

Important

This method must be called on the UI thread.

RequestPurchaseAsync(String) RequestPurchaseAsync(String) RequestPurchaseAsync(String) RequestPurchaseAsync(String) RequestPurchaseAsync(String)

Requests the purchase for the specified app or add-on and displays the UI that is used to complete the transaction via the Microsoft Store.

Important

This method must be called on the UI thread.

RequestPurchaseAsync(String, StorePurchaseProperties) RequestPurchaseAsync(String, StorePurchaseProperties) RequestPurchaseAsync(String, StorePurchaseProperties) RequestPurchaseAsync(String, StorePurchaseProperties) RequestPurchaseAsync(String, StorePurchaseProperties)

Requests the purchase for the specified app or add-on and displays the UI that is used to complete the transaction via the Microsoft Store. This method provides the option to specify additional details for a specific offer within a large catalog of products that are represented by a single listing in the Microsoft Store, including the product name to display to the user during the purchase.

Important

This method must be called on the UI thread.

RequestRateAndReviewAppAsync() RequestRateAndReviewAppAsync() RequestRateAndReviewAppAsync() RequestRateAndReviewAppAsync() RequestRateAndReviewAppAsync()

Requests the user to rate and review the app. This method will display the UI for the user to select a Store rating and add an optional Store review for the product.

Important

This method must be called on the UI thread.

RequestUninstallStorePackageAsync(Package) RequestUninstallStorePackageAsync(Package) RequestUninstallStorePackageAsync(Package) RequestUninstallStorePackageAsync(Package) RequestUninstallStorePackageAsync(Package)

Attempts to uninstall the specified optional package for the current app. This method also displays a UI dialog that requests permission for the operation.

RequestUninstallStorePackageByStoreIdAsync(String) RequestUninstallStorePackageByStoreIdAsync(String) RequestUninstallStorePackageByStoreIdAsync(String) RequestUninstallStorePackageByStoreIdAsync(String) RequestUninstallStorePackageByStoreIdAsync(String)

Attempts to uninstall the specified downloadable content (DLC) package for the current app. This method also displays a UI dialog that requests permission for the operation.

SetInstallOrderForAssociatedStoreQueueItemsAsync(IIterable<StoreQueueItem>) SetInstallOrderForAssociatedStoreQueueItemsAsync(IIterable<StoreQueueItem>) SetInstallOrderForAssociatedStoreQueueItemsAsync(IIterable<StoreQueueItem>) SetInstallOrderForAssociatedStoreQueueItemsAsync(IIterable<StoreQueueItem>) SetInstallOrderForAssociatedStoreQueueItemsAsync(IIterable<StoreQueueItem>)

Sets the order in which to install the specified packages in the download and installation queue for the current app.

TrySilentDownloadAndInstallStorePackageUpdatesAsync(IIterable<StorePackageUpdate>) TrySilentDownloadAndInstallStorePackageUpdatesAsync(IIterable<StorePackageUpdate>) TrySilentDownloadAndInstallStorePackageUpdatesAsync(IIterable<StorePackageUpdate>) TrySilentDownloadAndInstallStorePackageUpdatesAsync(IIterable<StorePackageUpdate>) TrySilentDownloadAndInstallStorePackageUpdatesAsync(IIterable<StorePackageUpdate>)

Attempts to download and install the specified package updates for the current app from the Microsoft Store without displaying a notification UI to the user.

TrySilentDownloadStorePackageUpdatesAsync(IIterable<StorePackageUpdate>) TrySilentDownloadStorePackageUpdatesAsync(IIterable<StorePackageUpdate>) TrySilentDownloadStorePackageUpdatesAsync(IIterable<StorePackageUpdate>) TrySilentDownloadStorePackageUpdatesAsync(IIterable<StorePackageUpdate>) TrySilentDownloadStorePackageUpdatesAsync(IIterable<StorePackageUpdate>)

Attempts to download the specified package updates for the current app from the Microsoft Store without displaying a notification UI to the user.

UninstallStorePackageAsync(Package) UninstallStorePackageAsync(Package) UninstallStorePackageAsync(Package) UninstallStorePackageAsync(Package) UninstallStorePackageAsync(Package)

Uninstalls the specified optional package for the current app without displaying a notification UI dialog to the user.

UninstallStorePackageByStoreIdAsync(String) UninstallStorePackageByStoreIdAsync(String) UninstallStorePackageByStoreIdAsync(String) UninstallStorePackageByStoreIdAsync(String) UninstallStorePackageByStoreIdAsync(String)

Uninstalls the specified downloadable content (DLC) package for the current app without displaying a notification UI dialog to the user.

Events

OfflineLicensesChanged OfflineLicensesChanged OfflineLicensesChanged OfflineLicensesChanged OfflineLicensesChanged

Raised when the status of the app's license changes (for example, the trial period has expired or the user has purchased the full version of the app).

See Also