Dela via


AppWindow Class

Definition

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

public ref class AppWindow sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 524288)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class AppWindow final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 524288)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class AppWindow
Public NotInheritable Class AppWindow
Inheritance
Object Platform::Object IInspectable AppWindow
Attributes

Windows requirements

Device family
Windows 10, version 1903 (introduced in 10.0.18362.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v8.0)

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.

To specify a preferred minimum size for the app window, use the WindowManagementPreview.SetPreferredMinSize method.

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

Gets the app content currently attached to the window.

DispatcherQueue

Gets the dispatcher queue for the app window.

Frame

Gets the frame for the app window.

IsVisible

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

PersistedStateId

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

Presenter

Gets the presenter for the app window.

Title

Gets or sets the displayed title of the app window.

TitleBar

Gets the title bar of the app window.

UIContext

Gets the UI context for the app window.

WindowingEnvironment

Gets the windowing environment for the app window.

Methods

ClearAllPersistedState()

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

ClearPersistedState(String)

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

CloseAsync()

Closes the app window.

GetDisplayRegions()

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

GetPlacement()

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

RequestMoveAdjacentToCurrentView()

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

RequestMoveAdjacentToWindow(AppWindow)

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

RequestMoveRelativeToCurrentViewContent(Point)

Makes a request to position the window at the specified offset relative to the current view.

RequestMoveRelativeToDisplayRegion(DisplayRegion, Point)

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

RequestMoveRelativeToWindowContent(AppWindow, Point)

Makes a request to position the window at the specified offset relative to the anchor window.

RequestMoveToDisplayRegion(DisplayRegion)

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

RequestSize(Size)

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

TryCreateAsync()

Attempts to asynchronously create a new instance of AppWindow.

TryShowAsync()

Attempts to asynchronously show the current app window.

Events

Changed

Occurs when a property of the app window has changed.

Closed

Occurs when the app window has been closed.

CloseRequested

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

Applies to