AppWindow AppWindow AppWindow AppWindow Class

Definition

Represents a system-managed container for the content of an app.

public : sealed class AppWindow
struct winrt::Windows::UI::WindowManagement::AppWindow
public sealed class AppWindow
Public NotInheritable Class AppWindow
Attributes

Windows 10 requirements

Device family
Windows 10, version 1903 (introduced v10.0.18362.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v8)

Remarks

Note

AppWindow is currently in preview. This means you can submit apps that use AppWindow to the Store, but some platform and framework components are known to not work with AppWindow (see Limitations).

An AppWindow can be used to represent a displayed portion of a Windows Runtime app when it has more than one window. It is similar in concept to an ApplicationView, but not the same in behavior and lifetime.

Unlike ApplicationView, each AppWindow does not have a corresponding CoreWindow. They all share the same UI processing thread (including the event dispatcher) from which they were created.

To obtain an object of this type, call AppWindow.TryCreateAsync.

To connect content to your AppWindow, call ElementCompositionPreview.SetAppWindowContent.

You can only connect XAML content to your AppWindow, there is no support for native DirectX or Holographic content.

Tip

For more info and code demonstrating AppWindow, see Show multiple views for an app and Show multiple views with AppWindow.

A sample that shows how to use the AppWindow API can be found in the Windows Universal Samples repo on GitHub under Samples/AppWindow.

Limitations

Limitations in the current preview version of AppWindow include (this is a non-exhaustive list):

  • Any API that uses the GetForCurrentView pattern is not working for AppWindow since the CurrentView refers to the ApplicationView which is a separate entity from the AppWindow.
  • Fullscreen media playback is unavailable in MediaElement or MediaPlayerElement.
  • MessageDialog will not be modal to the correct window, recommendation is to use ContentDialog instead.
  • WebView is not fully supported. You can use an in-proc WebView, but anything outside of static HTML content may or may not work properly.
  • If you set the Window.Current.Content property in XAML, it destroys all the XAML content in your AppWindow. Avoid using this as a pattern to reset your content when suspending your app if you use AppWindow.
  • Smooth Window Resize is not working for AppWindows. The frame and the content will resize independently, which can look unpolished when content layout is slow.
  • DisplayInformation is not accessible for AppWindow. If your AppWindow is on a different monitor than your ApplicationView you will not be able to query for the correct display information.
  • UserInteractionMode cannot be set for an AppWindow.
  • Print dialogs (2D and 3D) will not be parented to the correct window.
  • AppWindow cannot detect when edge gestures are being invoked.
  • AppWindow cannot be used to satisfy an activation request through ActivationViewSwitcher.

Properties

Content Content Content Content

Gets the app content currently attached to the window.

DispatcherQueue DispatcherQueue DispatcherQueue DispatcherQueue

Gets the dispatcher queue for the app window.

Frame Frame Frame Frame

Gets the frame for the app window.

IsVisible IsVisible IsVisible IsVisible

Gets a value that indicates whether the window can be seen on a display.

PersistedStateId PersistedStateId PersistedStateId PersistedStateId

Gets or sets a string that identifies this window for tracking and saving state.

Presenter Presenter Presenter Presenter

Gets the presenter for the app window.

Title Title Title Title

Gets or sets the displayed title of the app window.

TitleBar TitleBar TitleBar TitleBar

Gets the title bar of the app window.

UIContext UIContext UIContext UIContext

Gets the UI context for the app window.

WindowingEnvironment WindowingEnvironment WindowingEnvironment WindowingEnvironment

Gets the windowing environment for the app window.

Methods

ClearAllPersistedState() ClearAllPersistedState() ClearAllPersistedState() ClearAllPersistedState()

Clears any properties the system has saved for any window PersistedStateId for the given application.

ClearPersistedState(String) ClearPersistedState(String) ClearPersistedState(String) ClearPersistedState(String)

Clears any properties the system has saved for the window with the specified ID for the given application.

CloseAsync() CloseAsync() CloseAsync() CloseAsync()

Closes the app window.

GetDisplayRegions() GetDisplayRegions() GetDisplayRegions() GetDisplayRegions()

Returns the collection of display regions available for the app window.

GetPlacement() GetPlacement() GetPlacement() GetPlacement()

Returns a placement object that describes the app window's display region, offset, and size.

RequestMoveAdjacentToCurrentView() RequestMoveAdjacentToCurrentView() RequestMoveAdjacentToCurrentView() RequestMoveAdjacentToCurrentView()

Makes a request to position the window next to the current view.

RequestMoveAdjacentToWindow(AppWindow) RequestMoveAdjacentToWindow(AppWindow) RequestMoveAdjacentToWindow(AppWindow) RequestMoveAdjacentToWindow(AppWindow)

Makes a request to position the window next to the specified anchor window.

RequestMoveRelativeToDisplayRegion(DisplayRegion, Point) RequestMoveRelativeToDisplayRegion(DisplayRegion, Point) RequestMoveRelativeToDisplayRegion(DisplayRegion, Point) RequestMoveRelativeToDisplayRegion(DisplayRegion, Point)

Makes a request to position the window in the specified display region at the specified offset.

RequestMoveToDisplayRegion(DisplayRegion) RequestMoveToDisplayRegion(DisplayRegion) RequestMoveToDisplayRegion(DisplayRegion) RequestMoveToDisplayRegion(DisplayRegion)

Makes a request to position the window in the specified display region.

RequestSize(Size) RequestSize(Size) RequestSize(Size) RequestSize(Size)

Makes a request to set the window to the specified size.

TryCreateAsync() TryCreateAsync() TryCreateAsync() TryCreateAsync()

Attempts to asynchronously create a new instance of AppWindow.

TryShowAsync() TryShowAsync() TryShowAsync() TryShowAsync()

Attempts to asynchronously show the current app window.

Events

Changed Changed Changed Changed

Occurs when a property of the app window has changed.

Closed Closed Closed Closed

Occurs when the app window has been closed.

CloseRequested CloseRequested CloseRequested CloseRequested

Occurs after the window starts to close, but before it is closed and before the Closed event occurs.