CoreIndependentInputSource CoreIndependentInputSource CoreIndependentInputSource CoreIndependentInputSource Class


Surfaces core input API for interoperation scenarios.

public : sealed class CoreIndependentInputSource : ICoreInputSourceBase, ICorePointerInputSource
struct winrt::Windows::UI::Core::CoreIndependentInputSource : ICoreInputSourceBase, ICorePointerInputSource
public sealed class CoreIndependentInputSource : ICoreInputSourceBase, ICorePointerInputSource
Public NotInheritable Class CoreIndependentInputSource Implements ICoreInputSourceBase, ICorePointerInputSource
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)


Create an instance of this class by calling SwapChainBackgroundPanel::CreateCoreIndependentInputSource or SwapChainPanel::CreateCoreIndependentInputSource.

The CoreIndependentInputSource class enables an app to handle input and rendering independent of the XAML UI thread, because you're deliberately providing the input processing logic on a background thread. You must call CreateCoreIndependentInputSource from a non-UI thread, otherwise the CreateCoreIndependentInputSource method call will fail.

Initializing independent input

// Create a task to register for independent input and begin processing input messages.
auto workItemHandler = ref new WorkItemHandler([this] (IAsyncAction ^)
   // The CoreIndependentInputSource will raise pointer events for the specified device types on whichever thread it's created on.
   CoreIndependentInputSource^ coreInput = CreateCoreIndependentInputSource(
      Windows::UI::Core::CoreInputDeviceTypes::Mouse |
      Windows::UI::Core::CoreInputDeviceTypes::Touch |

   // Register for pointer events, which will be raised on the background thread.
   coreInput->PointerPressed += ref new TypedEventHandler<Object^, PointerEventArgs^>(this, &MyClass::OnPointerPressed);
   coreInput->PointerMoved += ref new TypedEventHandler<Object^, PointerEventArgs^>(this, &MyClass::OnPointerMoved);
   coreInput->PointerReleased += ref new TypedEventHandler<Object^, PointerEventArgs^>(this, &MyClass::OnPointerReleased);

   // Begin processing input messages as they're delivered.

// Run task on a dedicated high priority background thread.
m_inputLoopWorker = ThreadPool::RunAsync(workItemHandler, WorkItemPriority::High, WorkItemOptions::TimeSliced);

For more example code of how to use CreateCoreIndependentInputSource and CoreIndependentInputSource, see the DrawingPanel class definition that is part of the XAML SwapChainPanel DirectX interop sample.


Dispatcher Dispatcher Dispatcher Dispatcher

Gets the event dispatcher for the window.

DispatcherQueue DispatcherQueue DispatcherQueue DispatcherQueue

Gets the DispatcherQueue associated with this CoreIndependentInputSource.

HasCapture HasCapture HasCapture HasCapture

Gets a value that reports whether the window has pointer capture.

IsInputEnabled IsInputEnabled IsInputEnabled IsInputEnabled

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

PointerCursor PointerCursor PointerCursor PointerCursor

Gets or sets the cursor used by the UWP app.

PointerPosition PointerPosition PointerPosition PointerPosition

Gets the client coordinates of the pointer.


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

Disables pointer capture for the UWP app.

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

Enables pointer capture for the UWP app.


InputEnabled InputEnabled InputEnabled InputEnabled

Occurs when input is enabled or disabled for the UWP app.

PointerCaptureLost PointerCaptureLost PointerCaptureLost PointerCaptureLost

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

PointerEntered PointerEntered PointerEntered PointerEntered

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

PointerExited PointerExited PointerExited PointerExited

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

PointerMoved PointerMoved PointerMoved PointerMoved

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

PointerPressed PointerPressed PointerPressed PointerPressed

Occurs when a mouse button is clicked, or a touch or pen contact is detected, within the bounding rectangle of the UWP app.

PointerReleased PointerReleased PointerReleased PointerReleased

Occurs when a mouse button is released, or a touch or pen contact is lifted, within the bounding rectangle of the UWP app.

PointerWheelChanged PointerWheelChanged PointerWheelChanged PointerWheelChanged

Occurs when the wheel button is rotated.

See Also