The Windows 8 Store Application Object Model

While working on my latest Windows Store application, I found that I needed a better mental model of the relationships between the framework classes. Here are some quick sketches that cover the core objects and their interactions during application launch.

Core Objects

The diagram below shows the core objects common to all store applications:

Application Object Model              

An App class derived from the framework’s Application base class is the starting point. It represents the running process for the application and exposes basic events for startup and shutdown, as well as several other special events triggered by the operating system.

The sealed Window class represents the core container window created by the operating system to host the application’s user interface. It exposes several properties and events related to visibility and sizing. It acts as the host for the visual controls that compose the application.

The Frame class is a visual content container. It is attached to and completely fills the core Window object. It hosts and manages the lifetimes of the individual Page objects that form the user experience of an application. It provides a navigation framework with full backward and forward history stacks to allow movement between pages using a familiar browsing metaphor.

You can see an expanded view of these objects with their attributes and methods here:

WIndows.UI

 

Application Launch

The sequence diagram below shows the basic launch steps for a simple store application with a single Main page:

Application Activation

When a user launches the app, it triggers a call to the overloaded OnLaunched() event in the App class. This method instantiates a new root Frame object and attaches it to the framework’s current Window (there’s only one for the newly launched application).

Once the Frame is attached, a call to Navigate( typeof(MainPage) ) triggers the creation of the first page, fills the frame with it, and places it in the navigation history stack. It’s important to point out that the Frame’s navigation framework takes care of instantiating the requested pages, optionally reusing them if desired.

After the Frame is set up and the first page has been primed, a final method call to Window.Current.Activate() brings the application window to the forefront and shows it to the user.

That’s a quick tour of the Windows Store app model to show the fundamental objects and how they interact with each other as the application starts up.

Note: These models are based on a C# + XAML based application. The core object model is fundamentally the same for JavaScript + HTML5, but there are some differences in event names and object interactions due to language and runtime differences. I’ll show the JavaScript + HTML 5 versions of these same models in a future article.

As always, stay tuned to my twitter feed for Windows 8, Windows Azure and other Microsoft developer announcements, updates, and links: @clinted