Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Application Class

Encapsulates a Windows Presentation Foundation (WPF) application.

Namespace:  System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)

public class Application : DispatcherObject
<Application .../>

Application is a class that encapsulates WPF application-specific functionality, including the following:

Application implements the singleton pattern to provide shared access to its window, property, and resource scope services. Consequently, only one instance of the Application class can be created per AppDomain.

You can implement an Application using markup, markup and code-behind, or code. If Application is implemented with markup, whether markup or markup and code-behind, the markup file must be configured as an Microsoft build engine (MSBuild) ApplicationDefinition item.


A standalone application does not require an Application object; it is possible to implement a custom static entry point method (Main) that opens a window without creating an instance of Application. However, XAML browser applications (XBAPs) require an Application object.

The following example shows how a standard application is defined using only markup:

<Application xmlns="" />

The following example shows how a standard application is defined using only code:

using System; // STAThread 
using System.Windows; // Application 

namespace SDKSample
    public class AppCode : Application
        // Entry point method
        public static void Main()
            AppCode app = new AppCode();

The following example shows how a standard application is defined using a combination of markup and code-behind.

  x:Class="SDKSample.App" />
using System.Windows;  // Application 

namespace SDKSample
    public partial class App : Application { }

The public static (Shared in Visual Basic) members of this type are thread safe. In addition, the FindResource and TryFindResource methods and the Properties and Resources properties are thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0

Community Additions

© 2017 Microsoft