Export (0) Print
Expand All

Application Class

Encapsulates a Windows Presentation Foundation (WPF) application.

Namespace:  System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

public ref class Application : public DispatcherObject, 
	IQueryAmbient
<Application .../>

The Application type exposes the following members.

  NameDescription
Public methodApplicationInitializes a new instance of the Application class.
Top

  NameDescription
Public propertyStatic memberCurrentGets the Application object for the current AppDomain.
Public propertyDispatcherGets the Dispatcher this DispatcherObject is associated with. (Inherited from DispatcherObject.)
Public propertyMainWindowGets or sets the main window of the application.
Public propertyPropertiesGets a collection of application-scope properties.
Public propertyStatic memberResourceAssemblyGets or sets the Assembly that provides the pack uniform resource identifiers (URIs) for resources in a WPF application.
Public propertyResourcesGets or sets a collection of application-scope resources, such as styles and brushes.
Public propertyShutdownModeGets or sets the condition that causes the Shutdown method to be called.
Public propertyStartupUriGets or sets a UI that is automatically shown when an application starts.
Public propertyWindowsGets the instantiated windows in an application.
Top

  NameDescription
Public methodCheckAccessDetermines whether the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodFindResourceSearches for a user interface (UI) resource, such as a Style or Brush, with the specified key, and throws an exception if the requested resource is not found (see XAML Resources).
Public methodStatic memberGetContentStreamReturns a resource stream for a content data file that is located at the specified Uri (see WPF Application Resource, Content, and Data Files).
Public methodStatic memberGetCookieRetrieves a cookie for the location specified by a Uri.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodStatic memberGetRemoteStreamReturns a resource stream for a site-of-origin data file that is located at the specified Uri (see WPF Application Resource, Content, and Data Files).
Public methodStatic memberGetResourceStreamReturns a resource stream for a resource data file that is located at the specified Uri (see WPF Application Resource, Content, and Data Files).
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodStatic memberLoadComponent(Uri)Loads a XAML file that is located at the specified uniform resource identifier (URI), and converts it to an instance of the object that is specified by the root element of the XAML file.
Public methodStatic memberLoadComponent(Object, Uri)Loads a XAML file that is located at the specified uniform resource identifier (URI) and converts it to an instance of the object that is specified by the root element of the XAML file.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnActivatedRaises the Activated event.
Protected methodOnDeactivatedRaises the Deactivated event.
Protected methodOnExitRaises the Exit event.
Protected methodOnFragmentNavigationRaises the FragmentNavigation event.
Protected methodOnLoadCompletedRaises the LoadCompleted event.
Protected methodOnNavigatedRaises the Navigated event.
Protected methodOnNavigatingRaises the Navigating event.
Protected methodOnNavigationFailedRaises the NavigationFailed event.
Protected methodOnNavigationProgressRaises the NavigationProgress event.
Protected methodOnNavigationStoppedRaises the NavigationStopped event.
Protected methodOnSessionEndingRaises the SessionEnding event.
Protected methodOnStartupRaises the Startup event.
Public methodRun()Starts a Windows Presentation Foundation (WPF) application.
Public methodRun(Window)Starts a Windows Presentation Foundation (WPF) application and opens the specified window.
Public methodStatic memberSetCookieCreates a cookie for the location specified by a Uri.
Public methodShutdown()Shuts down an application.
Public methodShutdown(Int32)Shuts down an application that returns the specified exit code to the operating system.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodTryFindResourceSearches for the specified resource.
Public methodVerifyAccessEnforces that the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.)
Top

  NameDescription
Public eventActivatedOccurs when an application becomes the foreground application.
Public eventDeactivatedOccurs when an application stops being the foreground application.
Public eventDispatcherUnhandledExceptionOccurs when an exception is thrown by an application but not handled.
Public eventExitOccurs just before an application shuts down, and cannot be canceled.
Public eventFragmentNavigationOccurs when a navigator in the application begins navigation to a content fragment, Navigation occurs immediately if the desired fragment is in the current content, or after the source XAML content has been loaded if the desired fragment is in different content.
Public eventLoadCompletedOccurs when content that was navigated to by a navigator in the application has been loaded, parsed, and has begun rendering.
Public eventNavigatedOccurs when the content that is being navigated to by a navigator in the application has been found, although it may not have completed loading.
Public eventNavigatingOccurs when a new navigation is requested by a navigator in the application.
Public eventNavigationFailedOccurs when an error occurs while a navigator in the application is navigating to the requested content.
Public eventNavigationProgressOccurs periodically during a download that is being managed by a navigator in the application to provide navigation progress information.
Public eventNavigationStoppedOccurs when the StopLoading method of a navigator in the application is called, or when a new navigation is requested by a navigator while a current navigation is in progress.
Public eventSessionEndingOccurs when the user ends the Windows session by logging off or shutting down the operating system.
Public eventStartupOccurs when the Run method of the Application object is called.
Top

  NameDescription
Explicit interface implemetationPrivate methodIQueryAmbient::IsAmbientPropertyAvailableQueries for whether a specified ambient property is available in the current scope.
Top

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.

NoteNote

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="http://schemas.microsoft.com/winfx/2006/xaml/presentation" />

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

No code example is currently available or this language may not be supported.

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

<Application 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  x:Class="SDKSample.App" />
No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

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.

Show:
© 2014 Microsoft