CoreApplicationView CoreApplicationView CoreApplicationView CoreApplicationView Class

Definition

Represents an app window and its thread.

public : sealed class CoreApplicationView : ICoreApplicationView, ICoreApplicationView2, ICoreApplicationView3, ICoreApplicationView5, ICoreApplicationView6
public sealed class CoreApplicationView : ICoreApplicationView, ICoreApplicationView2, ICoreApplicationView3, ICoreApplicationView5, ICoreApplicationView6
Public NotInheritable Class CoreApplicationView Implements ICoreApplicationView, ICoreApplicationView2, ICoreApplicationView3, ICoreApplicationView5, ICoreApplicationView6
// This class does not provide a public constructor.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

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).

The following code snippet demonstrates the activation of the CoreApplicationView and the associated CoreWindow in a view provider implementation.


ref class MyFrameworkView : public IFrameworkView
{
// ...
virtual void Initialize(
        _In_ CoreApplicationView^ applicationView
        )
    {
        applicationView->Activated +=
            ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &MyFrameworkView::OnActivated);
    }

// ...

void OnActivated(
        _In_ CoreApplicationView^ applicationView,
        _In_ IActivatedEventArgs^ args
        )
    {
        // Activate the application window, making it visible and enabling it to receive events.
        CoreWindow::GetForCurrentThread()->Activate();
    }

// ...
}

Properties

CoreWindow CoreWindow CoreWindow CoreWindow

Gets the app window associated with the current view.

public : CoreWindow CoreWindow { get; }
public CoreWindow CoreWindow { get; }
Public ReadOnly Property CoreWindow As CoreWindow
var coreWindow = coreApplicationView.coreWindow;
Value
CoreWindow CoreWindow CoreWindow CoreWindow

The app window.

Dispatcher Dispatcher Dispatcher Dispatcher

Gets the event message dispatcher associated with the current view.

public : CoreDispatcher Dispatcher { get; }
public CoreDispatcher Dispatcher { get; }
Public ReadOnly Property Dispatcher As CoreDispatcher
var coreDispatcher = coreApplicationView.dispatcher;
Value
CoreDispatcher CoreDispatcher CoreDispatcher CoreDispatcher

The event message dispatcher.

DispatcherQueue DispatcherQueue DispatcherQueue DispatcherQueue

Gets the DispatcherQueue for the window.

public : DispatcherQueue DispatcherQueue { get; }
public DispatcherQueue DispatcherQueue { get; }
Public ReadOnly Property DispatcherQueue As DispatcherQueue
var dispatcherQueue = coreApplicationView.dispatcherQueue;
Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

Remarks

The DispatcherQueue allows you to run your tasks on the thread associated with the DispatcherQueue instance. To make UI changes on a CoreApplicationView from a different thread, use the DispatcherQueue from that CoreApplicationView.

IsComponent IsComponent IsComponent IsComponent

Gets whether the app was launched as a component that is embedded in another app.

This property is reserved for internal use and is not intended to be used in your code.

public : Platform::Boolean IsComponent { get; }
public bool IsComponent { get; }
Public ReadOnly Property IsComponent As bool
var bool = coreApplicationView.isComponent;
Value
Platform::Boolean bool bool bool

True if the app was launched as a component that is embedded in another app; false otherwise.

IsHosted IsHosted IsHosted IsHosted

Gets the value that indicates whether this app view is hosted or not.

public : Platform::Boolean IsHosted { get; }
public bool IsHosted { get; }
Public ReadOnly Property IsHosted As bool
var bool = coreApplicationView.isHosted;
Value
Platform::Boolean bool bool bool

If true, this app view is hosted; if false, it is not.

IsMain IsMain IsMain IsMain

Gets a value that indicates whether this app view is the main app view or not.

public : Platform::Boolean IsMain { get; }
public bool IsMain { get; }
Public ReadOnly Property IsMain As bool
var bool = coreApplicationView.isMain;
Value
Platform::Boolean bool bool bool

If true, this app view is the main; if false, it is not.

Properties Properties Properties Properties

Gets properties that the app can associate with the view.

public : IPropertySet Properties { get; }
public IPropertySet Properties { get; }
Public ReadOnly Property Properties As IPropertySet
var iPropertySet = coreApplicationView.properties;
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Remarks

Properties stored here are guaranteed to have a lifetime equal to the CoreApplicationView.

TitleBar TitleBar TitleBar TitleBar

Gets the title bar associated with the current view.

public : CoreApplicationViewTitleBar TitleBar { get; }
public CoreApplicationViewTitleBar TitleBar { get; }
Public ReadOnly Property TitleBar As CoreApplicationViewTitleBar
var coreApplicationViewTitleBar = coreApplicationView.titleBar;

Events

Activated Activated Activated Activated

Occurs when the view is activated.

public : event TypedEventHandler Activated<CoreApplicationView,  IActivatedEventArgs>
public event TypedEventHandler Activated<CoreApplicationView,  IActivatedEventArgs>
Public Event TypedEventHandler Activated( Of ( Of CoreApplicationView ), ( Of  IActivatedEventArgs ))
function onActivated(eventArgs){/* Your code */}


coreApplicationView.addEventListener("activated", onActivated);
coreApplicationView.removeEventListener("activated", onActivated);
See Also

HostedViewClosing HostedViewClosing HostedViewClosing HostedViewClosing

Indicates that the hosted view is closing. Provides an opportunity for hosted window scenarios to defer the tear down of the hosted view.

public : event TypedEventHandler HostedViewClosing<CoreApplicationView,  HostedViewClosingEventArgs>
public event TypedEventHandler HostedViewClosing<CoreApplicationView,  HostedViewClosingEventArgs>
Public Event TypedEventHandler HostedViewClosing( Of ( Of CoreApplicationView ), ( Of  HostedViewClosingEventArgs ))
function onHostedViewClosing(eventArgs){/* Your code */}


coreApplicationView.addEventListener("hostedViewClosing", onHostedViewClosing);
coreApplicationView.removeEventListener("hostedViewClosing", onHostedViewClosing);

Remarks

Handling this event provides an opportunity to perform cleanup tasks such as closing files, flushing buffers to disk, and so on.

See Also