MSDN Community

Your source for Windows Development

📦

Windows.ApplicationModel

Provides access to the core application model of Windows. This namespace contains types that represent the application, its lifecycle, and its interactions with the Windows operating system.

Classes

🏢

Package

Represents a package that is installed on the device. Provides information about the application's identity, content, and resources.

View Details
⚙️

PackageId

Represents the unique identifier for a package, including its name, version, and publisher.

View Details
📅

PackageVersion

Represents the version of a package.

View Details

Commonly Used Members

The Windows.ApplicationModel namespace is the entry point for managing core application properties and lifecycle events.

Methods

Package Current

Gets the package that contains the current application.

Windows.ApplicationModel.Package.Current
string AppContext.BaseDirectory

Gets the base directory of the application.

string appDir = Windows.ApplicationModel.Package.Current.InstalledLocation.Path;

Events

event EventHandler PackageInstalling

Occurs when a package installation begins.

Use this event to respond to new package installations.

event EventHandler PackageStatusChanged

Occurs when the status of a package changes.

Useful for monitoring the health and availability of installed packages.

Key Concepts

  • Package Management: Understanding how applications are packaged and deployed on Windows.
  • Application Lifecycle: Responding to events like activation, suspension, and resuming.
  • Resource Access: Accessing application resources such as files and directories.
  • Package Identity: Identifying your application uniquely on the system.

Example Usage

Here's a simple example of how to get the current package's display name:


using Windows.ApplicationModel;

// ...

string appName = Package.Current.DisplayName;
System.Diagnostics.Debug.WriteLine($"Application Name: {appName}");