Windows.ApplicationModel.PackageId

Overview

Represents the unique identity of a package. Every Windows Store app (and some system components) is identified by a PackageId, which includes details like the package name, publisher, and version.

This structure is immutable and provides a reliable way to reference and compare different package identities.

Declaration

namespace Windows.ApplicationModel
{
    public sealed class PackageId
    {
        // Properties
        public string Architecture { get; }
        public string FamilyName { get; }
        public string FullName { get; }
        public string Name { get; }
        public PackageVersion Version { get; }
        public string Publisher { get; }
        public string PublisherId { get; }
    }
}

Properties

Property Description
Architecture Gets the processor architecture of the package.
FamilyName Gets the package family name. This is a combination of the package name and publisher ID.
FullName Gets the full string representation of the package identity.
Name Gets the name of the package.
Version Gets the version of the package.
Publisher Gets the publisher of the package.
PublisherId Gets the ID of the package publisher.

Remarks

The PackageId is fundamental for many UWP APIs that interact with installed applications, such as querying for installed packages, launching other apps, or managing app resources.

It's important to note that PackageId objects are immutable, meaning their values cannot be changed after creation.

Example Usage

Here's a C# example showing how to retrieve the PackageId of the current application:

using Windows.ApplicationModel;
using Windows.UI.Xaml;

public sealed partial class MainPage : Page
{
    public MainPage()
    {
        this.InitializeComponent();

        PackageId packageId = Package.Current.Id;

        // Displaying some properties
        var packageNameTextBlock.Text = $"Package Name: {packageId.Name}";
        var packageVersionTextBlock.Text = $"Package Version: {packageId.Version.Major}.{packageId.Version.Minor}.{packageId.Version.Build}.{packageId.Version.Revision}";
        var packageFamilyNameTextBlock.Text = $"Package Family Name: {packageId.FamilyName}";
    }
}