CoreWindow CoreWindow CoreWindow CoreWindow Class

Definition

Some information relates to pre-released product which may be substantially modified before it’s commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Prerelease APIs are identified by a Prerelease label.

[Contains prerelease APIs.]
Represents the Windows Store app with input events and basic user interface behaviors.

public : sealed class CoreWindow : ICorePointerRedirector, ICoreWindow, ICoreWindow2, ICoreWindow3, ICoreWindow4, ICoreWindow5public sealed class CoreWindow : ICorePointerRedirector, ICoreWindow, ICoreWindow2, ICoreWindow3, ICoreWindow4, ICoreWindow5Public NotInheritable Class CoreWindow Implements ICorePointerRedirector, ICoreWindow, ICoreWindow2, ICoreWindow3, ICoreWindow4, ICoreWindow5// This API is not available in Javascript.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

New instances of this class are obtained by calling CoreApplication.CreateNewView and then inspecting the CoreWindow property on the returned CoreApplicationView instance. Or you can obtain existing CoreWindow instances for a running app from the CoreApplication.Views property, or by calling CoreWindow.GetForCurrentThread, as seen in the following example.

void MyCoreWindowEvents::Run() // this is an implementation of IFrameworkView::Run() used to show context
{
    CoreWindow::GetForCurrentThread()->Activate();

    /...

    CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessUntilQuit);
}
Note

: This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX).

Properties

ActivationMode ActivationMode ActivationMode ActivationMode

Prerelease. Gets a value that indicates the activation state of the window.

public : CoreWindowActivationMode ActivationMode { get; }public CoreWindowActivationMode ActivationMode { get; }Public ReadOnly Property ActivationMode As CoreWindowActivationMode// This API is not available in Javascript.
Value
CoreWindowActivationMode CoreWindowActivationMode CoreWindowActivationMode CoreWindowActivationMode

A value that indicates the activation state of the window.

Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.16257.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

AutomationHostProvider AutomationHostProvider AutomationHostProvider AutomationHostProvider

Gets the automation provider assigned to this window.

public : PlatForm::Object AutomationHostProvider { get; }public object AutomationHostProvider { get; }Public ReadOnly Property AutomationHostProvider As object// This API is not available in Javascript.
Value
PlatForm::Object object object object

The automation provider for this window.

Bounds Bounds Bounds Bounds

Gets the bounding rectangle of the window.

public : Rect Bounds { get; }public Rect Bounds { get; }Public ReadOnly Property Bounds As Rect// This API is not available in Javascript.
Value
Rect Rect Rect Rect

The bounding rectangle of the window, in device-independent pixels (DIPs).

Remarks

To convert from DIPs to physical pixels (and back), use these equations (where DPI is the dots per inch value for the screen):

  • DIP value = (physical pixel x 96) / DPI
  • physical pixel value = (DIP x DPI) / 96

CustomProperties CustomProperties CustomProperties CustomProperties

Gets the set of custom properties for the window.

public : IPropertySet CustomProperties { get; }public IPropertySet CustomProperties { get; }Public ReadOnly Property CustomProperties As IPropertySet// This API is not available in Javascript.
Value
IPropertySet IPropertySet IPropertySet IPropertySet

The set of custom properties for the window, represented as tuples.

See Also

Dispatcher Dispatcher Dispatcher Dispatcher

Gets the event dispatcher for the window.

public : CoreDispatcher Dispatcher { get; }public CoreDispatcher Dispatcher { get; }Public ReadOnly Property Dispatcher As CoreDispatcher// This API is not available in Javascript.
Value
CoreDispatcher CoreDispatcher CoreDispatcher CoreDispatcher

The event dispatcher for the window.

See Also

DispatcherQueue DispatcherQueue DispatcherQueue DispatcherQueue

Prerelease. Gets the DispatcherQueue for the window.

public : DispatcherQueue DispatcherQueue { get; }public DispatcherQueue DispatcherQueue { get; }Public ReadOnly Property DispatcherQueue As DispatcherQueue// This API is not available in Javascript.
Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.16257.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

FlowDirection FlowDirection FlowDirection FlowDirection

Gets or sets the horizontal origin of the window's reading order alignment. If the language specified by the user interface is right-aligned (such as in Arabic or Hebrew), the horizontal origin of the reading layout for the window is on the right edge.

public : CoreWindowFlowDirection FlowDirection { get; set; }public CoreWindowFlowDirection FlowDirection { get; set; }Public ReadWrite Property FlowDirection As CoreWindowFlowDirection// This API is not available in Javascript.
Value
CoreWindowFlowDirection CoreWindowFlowDirection CoreWindowFlowDirection CoreWindowFlowDirection

The flow direction of the window's reading layout.

See Also

IsInputEnabled IsInputEnabled IsInputEnabled IsInputEnabled

Gets or sets a value that indicates whether input is enabled for the app.

public : PlatForm::Boolean IsInputEnabled { get; set; }public bool IsInputEnabled { get; set; }Public ReadWrite Property IsInputEnabled As bool// This API is not available in Javascript.
Value
PlatForm::Boolean bool bool bool

True if input is enabled for the app; false if it is disabled.

PointerCursor PointerCursor PointerCursor PointerCursor

Gets or sets the cursor used by the app.

public : CoreCursor PointerCursor { get; set; }public CoreCursor PointerCursor { get; set; }Public ReadWrite Property PointerCursor As CoreCursor// This API is not available in Javascript.
Value
CoreCursor CoreCursor CoreCursor CoreCursor

The app's cursor.

PointerPosition PointerPosition PointerPosition PointerPosition

Gets the client coordinates of the pointer.

public : Point PointerPosition { get; set; }public Point PointerPosition { get; set; }Public ReadWrite Property PointerPosition As Point// This API is not available in Javascript.
Value
Point Point Point Point

The position of the pointer in device-independent pixel (DIP).

Remarks

You cannot read the pointer position with this API when the lock screen is present.

Visible Visible Visible Visible

Gets a value that indicates whether the window is visible.

public : PlatForm::Boolean Visible { get; }public bool Visible { get; }Public ReadOnly Property Visible As bool// This API is not available in Javascript.
Value
PlatForm::Boolean bool bool bool

True if the window is visible on the screen; false if it is not.

Methods

Activate() Activate() Activate() Activate()

Activates the window. This method is called to present the window on the screen.

public : void Activate()public void Activate()Public Function Activate() As void// This API is not available in Javascript.

Remarks

The window is presented if the app is the foreground window. If the app has more than one window, the activating window is presented when the app is set to the foreground.

Close() Close() Close() Close()

Closes a secondary window and exits the message loop.

public : void Close()public void Close()Public Function Close() As void// This API is not available in Javascript.

Remarks

This method also causes the ProcessEvents operation to exit the event-processing loop.

GetAsyncKeyState(VirtualKey) GetAsyncKeyState(VirtualKey) GetAsyncKeyState(VirtualKey) GetAsyncKeyState(VirtualKey)

Asynchronously retrieves the state of a virtual key.

public : CoreVirtualKeyStates GetAsyncKeyState(VirtualKey virtualKey)public CoreVirtualKeyStates GetAsyncKeyState(VirtualKey virtualKey)Public Function GetAsyncKeyState(virtualKey As VirtualKey) As CoreVirtualKeyStates// This API is not available in Javascript.
Parameters
virtualKey
VirtualKey VirtualKey VirtualKey VirtualKey

The virtual key for which state is returned.

Returns

The flags indicating the current state of the supplied virtual key when the input event fired.

Note

All keys support the Locked state (not just the standard Caps Lock and Num Lock keys).

See Also

GetCurrentKeyEventDeviceId() GetCurrentKeyEventDeviceId() GetCurrentKeyEventDeviceId() GetCurrentKeyEventDeviceId()

Retrieves the unique ID for the input device that generated this key event.

GetCurrentKeyEventDeviceId is not supported for all input devices.

public : PlatForm::String GetCurrentKeyEventDeviceId()public string GetCurrentKeyEventDeviceId()Public Function GetCurrentKeyEventDeviceId() As string// This API is not available in Javascript.
Returns
PlatForm::String string string string

A unique identifier for the input device associated with the key event, or an empty string. The same device can be assigned a different ID each time it is connected.

After a key event is processed, this method returns an empty string.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Remarks

Use GetCurrentKeyEventDeviceId to differentiate between devices that can generate key events, such as multiple Xbox controllers. The device id is useful for associating the input device with a specific user account.

To get a valid device ID, this method must be called from your KeyUp and KeyDown event handlers.

GetForCurrentThread() GetForCurrentThread() GetForCurrentThread() GetForCurrentThread()

Gets the CoreWindow instance for the currently active thread.

public : static CoreWindow GetForCurrentThread()public static CoreWindow GetForCurrentThread()Public Static Function GetForCurrentThread() As CoreWindow// This API is not available in Javascript.
Returns

The CoreWindow for the currently active thread.

GetKeyState(VirtualKey) GetKeyState(VirtualKey) GetKeyState(VirtualKey) GetKeyState(VirtualKey)

Retrieves the state of a virtual key.

public : CoreVirtualKeyStates GetKeyState(VirtualKey virtualKey)public CoreVirtualKeyStates GetKeyState(VirtualKey virtualKey)Public Function GetKeyState(virtualKey As VirtualKey) As CoreVirtualKeyStates// This API is not available in Javascript.
Parameters
virtualKey
VirtualKey VirtualKey VirtualKey VirtualKey

The virtual key for which state is returned.

Returns

The flags indicating the current state of the supplied virtual key when the input event fired.

Note

All keys support the Locked state (not just the standard Caps Lock and Num Lock keys).

See Also

ReleasePointerCapture() ReleasePointerCapture() ReleasePointerCapture() ReleasePointerCapture()

Dissociates pointer input from the app, if previously associated through SetPointerCapture, and restores normal pointer input processing.

public : void ReleasePointerCapture()public void ReleasePointerCapture()Public Function ReleasePointerCapture() As void// This API is not available in Javascript.

SetPointerCapture() SetPointerCapture() SetPointerCapture() SetPointerCapture()

Associates pointer input with the app. Once a pointer is captured, all subsequent events associated with that pointer are fired by the app.

public : void SetPointerCapture()public void SetPointerCapture()Public Function SetPointerCapture() As void// This API is not available in Javascript.

Remarks

A pointer can be captured only by a single app at any time. Only the foreground window can capture the pointer. Pointer events continue even if the pointer moves outside the bounds of the app.

A pointer can only be captured when contact is detected (mouse button pressed, touch contact down, stylus in contact), and the pointer is within the bounding rectangle of the app.

The pointer is released on a PointerReleased or a PointerCaptureLost event, or ReleasePointerCapture is explicitly called.

Events

Activated Activated Activated Activated

Is fired when the window completes activation or deactivation.

public : event TypedEventHandler Activated<CoreWindow,  WindowActivatedEventArgs>public event TypedEventHandler Activated<CoreWindow,  WindowActivatedEventArgs>Public Event Activated<CoreWindow,  WindowActivatedEventArgs>// This API is not available in Javascript.

AutomationProviderRequested AutomationProviderRequested AutomationProviderRequested AutomationProviderRequested

Is fired when a request for an automation handler is generated.

public : event TypedEventHandler AutomationProviderRequested<CoreWindow,  AutomationProviderRequestedEventArgs>public event TypedEventHandler AutomationProviderRequested<CoreWindow,  AutomationProviderRequestedEventArgs>Public Event AutomationProviderRequested<CoreWindow,  AutomationProviderRequestedEventArgs>// This API is not available in Javascript.

CharacterReceived CharacterReceived CharacterReceived CharacterReceived

Is fired when a new character is received by the input queue.

public : event TypedEventHandler CharacterReceived<CoreWindow,  CharacterReceivedEventArgs>public event TypedEventHandler CharacterReceived<CoreWindow,  CharacterReceivedEventArgs>Public Event CharacterReceived<CoreWindow,  CharacterReceivedEventArgs>// This API is not available in Javascript.

Remarks

Apps do not receive this event when an Input Method Editor (IME) is enabled. The Input Method Editor (IME) handles all keyboard input and sets Handled to true.

Closed Closed Closed Closed

Is fired when the app terminates.

public : event TypedEventHandler Closed<CoreWindow,  CoreWindowEventArgs>public event TypedEventHandler Closed<CoreWindow,  CoreWindowEventArgs>Public Event Closed<CoreWindow,  CoreWindowEventArgs>// This API is not available in Javascript.

Remarks

Note

Apps are typically suspended, not terminated. As a result, this event is rarely fired, if ever.

See Also

ClosestInteractiveBoundsRequested ClosestInteractiveBoundsRequested ClosestInteractiveBoundsRequested ClosestInteractiveBoundsRequested

Note

Not intended for general use.

Occurs when a framework input manager requests the bounding rectangle of an interactive element within a specific bounding rectangle and closest to a specific pointer.

public : event TypedEventHandler ClosestInteractiveBoundsRequested<CoreWindow,  ClosestInteractiveBoundsRequestedEventArgs>public event TypedEventHandler ClosestInteractiveBoundsRequested<CoreWindow,  ClosestInteractiveBoundsRequestedEventArgs>Public Event ClosestInteractiveBoundsRequested<CoreWindow,  ClosestInteractiveBoundsRequestedEventArgs>// This API is not available in Javascript.
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

InputEnabled InputEnabled InputEnabled InputEnabled

Occurs when input is enabled or disabled for the app.

public : event TypedEventHandler InputEnabled<CoreWindow,  InputEnabledEventArgs>public event TypedEventHandler InputEnabled<CoreWindow,  InputEnabledEventArgs>Public Event InputEnabled<CoreWindow,  InputEnabledEventArgs>// This API is not available in Javascript.

KeyDown KeyDown KeyDown KeyDown

Is fired when a non-system key is pressed.

public : event TypedEventHandler KeyDown<CoreWindow,  KeyEventArgs>public event TypedEventHandler KeyDown<CoreWindow,  KeyEventArgs>Public Event KeyDown<CoreWindow,  KeyEventArgs>// This API is not available in Javascript.

Remarks

Apps do not receive this event when an Input Method Editor (IME) is enabled. The Input Method Editor (IME) handles all keyboard input and sets Handled to true.

KeyUp KeyUp KeyUp KeyUp

Is fired when a non-system key is released after a press.

public : event TypedEventHandler KeyUp<CoreWindow,  KeyEventArgs>public event TypedEventHandler KeyUp<CoreWindow,  KeyEventArgs>Public Event KeyUp<CoreWindow,  KeyEventArgs>// This API is not available in Javascript.

Remarks

Apps do not receive this event when an IME is enabled. The Input Method Editor (IME) handles all keyboard input and sets Handled to true.

PointerCaptureLost PointerCaptureLost PointerCaptureLost PointerCaptureLost

Occurs when a pointer moves to another app. This event is raised after PointerExited and is the final event received by the app for this pointer.

public : event TypedEventHandler PointerCaptureLost<CoreWindow,  PointerEventArgs>public event TypedEventHandler PointerCaptureLost<CoreWindow,  PointerEventArgs>Public Event PointerCaptureLost<CoreWindow,  PointerEventArgs>// This API is not available in Javascript.
See Also

PointerEntered PointerEntered PointerEntered PointerEntered

Occurs when a pointer moves into the bounding box of the app.

public : event TypedEventHandler PointerEntered<CoreWindow,  PointerEventArgs>public event TypedEventHandler PointerEntered<CoreWindow,  PointerEventArgs>Public Event PointerEntered<CoreWindow,  PointerEventArgs>// This API is not available in Javascript.

Remarks

For touch input, the app receives this event before a PointerPressed event.

See Also

PointerExited PointerExited PointerExited PointerExited

Occurs when the pointer moves outside the bounding box of the app.

public : event TypedEventHandler PointerExited<CoreWindow,  PointerEventArgs>public event TypedEventHandler PointerExited<CoreWindow,  PointerEventArgs>Public Event PointerExited<CoreWindow,  PointerEventArgs>// This API is not available in Javascript.

Remarks

For touch input, the app receives this event before a PointerReleased event.

See Also

PointerMoved PointerMoved PointerMoved PointerMoved

Occurs when a pointer moves within the bounding box of the app.

public : event TypedEventHandler PointerMoved<CoreWindow,  PointerEventArgs>public event TypedEventHandler PointerMoved<CoreWindow,  PointerEventArgs>Public Event PointerMoved<CoreWindow,  PointerEventArgs>// This API is not available in Javascript.
See Also

PointerPressed PointerPressed PointerPressed PointerPressed

Occurs when a mouse button is clicked, or the digitizer surface has been touched by a finger or pen, within the bounding rectangle of the app.

An interaction session starts when a single contact is detected and ends when that contact, and all subsequent contacts in the same session, are no longer detected.

This event is fired for the first contact detected in the interaction session. Details for all other concurrent contact pointers are exposed through a PointerPointProperties object (obtained by getting the Properties property from a PointerPoint object).

public : event TypedEventHandler PointerPressed<CoreWindow,  PointerEventArgs>public event TypedEventHandler PointerPressed<CoreWindow,  PointerEventArgs>Public Event PointerPressed<CoreWindow,  PointerEventArgs>// This API is not available in Javascript.
See Also

PointerReleased PointerReleased PointerReleased PointerReleased

Occurs when a pressed mouse button is released, or a touch or pen contact is lifted from the digitizer surface, within the bounding rectangle of the app (or outside the bounding rectangle, if the pointer is captured).

public : event TypedEventHandler PointerReleased<CoreWindow,  PointerEventArgs>public event TypedEventHandler PointerReleased<CoreWindow,  PointerEventArgs>Public Event PointerReleased<CoreWindow,  PointerEventArgs>// This API is not available in Javascript.

Remarks

An interaction session starts when a single contact is detected and ends when that contact, and all subsequent contacts in the same session, are no longer detected.

This event is fired for each contact detected in the interaction session (except for mouse, where this event is fired only when the last mouse button is released).

See Also

PointerRoutedAway PointerRoutedAway PointerRoutedAway PointerRoutedAway

Occurs on the process receiving input when the pointer input is routed to another process.

public : event TypedEventHandler PointerRoutedAway<ICorePointerRedirector,  PointerEventArgs>public event TypedEventHandler PointerRoutedAway<ICorePointerRedirector,  PointerEventArgs>Public Event PointerRoutedAway<ICorePointerRedirector,  PointerEventArgs>// This API is not available in Javascript.
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10586.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v2)

Remarks

This event is not fired on a PointerReleased event.

See Also

PointerRoutedReleased PointerRoutedReleased PointerRoutedReleased PointerRoutedReleased

Occurs on a process associated with, but not currently receiving input from, a pointer that fires a PointerReleased event on a different process.

public : event TypedEventHandler PointerRoutedReleased<ICorePointerRedirector,  PointerEventArgs>public event TypedEventHandler PointerRoutedReleased<ICorePointerRedirector,  PointerEventArgs>Public Event PointerRoutedReleased<ICorePointerRedirector,  PointerEventArgs>// This API is not available in Javascript.
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10586.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v2)
See Also

PointerRoutedTo PointerRoutedTo PointerRoutedTo PointerRoutedTo

Occurs on the process not currently receiving input, but designated to begin receiving input from another process.

public : event TypedEventHandler PointerRoutedTo<ICorePointerRedirector,  PointerEventArgs>public event TypedEventHandler PointerRoutedTo<ICorePointerRedirector,  PointerEventArgs>Public Event PointerRoutedTo<ICorePointerRedirector,  PointerEventArgs>// This API is not available in Javascript.
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10586.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v2)

Remarks

This event is not fired on a PointerPressed event.

See Also

PointerWheelChanged PointerWheelChanged PointerWheelChanged PointerWheelChanged

Occurs when the wheel button is rotated.

public : event TypedEventHandler PointerWheelChanged<CoreWindow,  PointerEventArgs>public event TypedEventHandler PointerWheelChanged<CoreWindow,  PointerEventArgs>Public Event PointerWheelChanged<CoreWindow,  PointerEventArgs>// This API is not available in Javascript.
See Also

ResizeCompleted ResizeCompleted ResizeCompleted ResizeCompleted

Occurs when a user finishes resizing the window.

public : event TypedEventHandler ResizeCompleted<CoreWindow,  object>public event TypedEventHandler ResizeCompleted<CoreWindow,  object>Public Event ResizeCompleted<CoreWindow,  object>// This API is not available in Javascript.
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

ResizeStarted ResizeStarted ResizeStarted ResizeStarted

Occurs when a user starts to resize the window.

public : event TypedEventHandler ResizeStarted<CoreWindow,  object>public event TypedEventHandler ResizeStarted<CoreWindow,  object>Public Event ResizeStarted<CoreWindow,  object>// This API is not available in Javascript.
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

SizeChanged SizeChanged SizeChanged SizeChanged

Occurs when the window size is changed.

public : event TypedEventHandler SizeChanged<CoreWindow,  WindowSizeChangedEventArgs>public event TypedEventHandler SizeChanged<CoreWindow,  WindowSizeChangedEventArgs>Public Event SizeChanged<CoreWindow,  WindowSizeChangedEventArgs>// This API is not available in Javascript.

Remarks

The SizeChanged event is exposed to XAML apps as the Window.SizeChanged event and to HTML apps as the window.resize event.

This event occurs when the window size changes or when one of the following properties changes:

TouchHitTesting TouchHitTesting TouchHitTesting TouchHitTesting

Occurs when a touch contact area intersects the bounding rectangle (or polygon) of a window that is registered for touch hit testing.

public : event TypedEventHandler TouchHitTesting<CoreWindow,  TouchHitTestingEventArgs>public event TypedEventHandler TouchHitTesting<CoreWindow,  TouchHitTestingEventArgs>Public Event TouchHitTesting<CoreWindow,  TouchHitTestingEventArgs>// This API is not available in Javascript.

VisibilityChanged VisibilityChanged VisibilityChanged VisibilityChanged

Is fired when the window visibility is changed.

public : event TypedEventHandler VisibilityChanged<CoreWindow,  VisibilityChangedEventArgs>public event TypedEventHandler VisibilityChanged<CoreWindow,  VisibilityChangedEventArgs>Public Event VisibilityChanged<CoreWindow,  VisibilityChangedEventArgs>// This API is not available in Javascript.

See Also