UWP CoreApplication / Application Vs CoreApplicationView / ApplicationView Vs CoreWindow / Window

I find a question on Stack Overflow CoreApplicationView vs CoreWindow vs ApplicationView, so I write this post for the answer.

This post is written in multiple languages. Please select yours:

The namespace

Sometimes we have to view the full class names with namespaces to determine their meanings.

Extra, if you’re interested in the titlebar,

Extra, if you’re interested in the threading model,

We can split them into Windows.ApplicationModel and Windows.UI, or split them into Core and Xaml.

The CoreApplication and CoreApplicationView manage the application model, and the Application, CoreWindow and Window manage the application inner UI. The CoreApplication, CoreApplicationView and CoreWindow manages the core functions, but the Application and Window manage the XAML UI.

From top to bottom

From top to bottom is from Application to Window, then to XAML. It’s obvious that the application contains windows and the window contains the inner XAML UI. Then, what’s the real relationship?

The CoreApplication manages all the views of a UWP application and the CoreApplicationView is the view that it manages directly. A CoreApplicationView contains a CoreWindow as the window and a CoreDispatcher as the threading model.

UWP application view
▲ UWP application view

You can read Show multiple views for an app - UWP app developer - Microsoft Docs to learn how to write multiple views applications. You’ll know more about the relationship between the CoreApplication and the CoreApplicationView.

CoreWindow is the window that we are all familiar with. Windows.UI.XAML.Window encapsulate the CoreWindow for easier usage. CoreDispatcher is the threading model based on the windows message loop. It’s the CoreDispatcher that keeps the window to show all the time without being disposed.

For outer or for inner

Most UWP developers are normal developers, so we should stand on their side to think about the outer and the inner. Normal UWP developers start writing code from MainPage, so the outer is out of the page and the inner is the XAML content of the page.

The outer part contains CoreApplication, CoreApplicationView and CoreWindow while the inner part contains Application and Window. Is it strange that the Application and the Window are the inner part? The reason is that they manage the XAML part of the application and the window.

The Window is the encapsulation of the CoreWindow to provide extra XAML UI functions. The same to the ApplicationView, it is the encapsulation of the CoreApplication providing extra XAML UI functions.

In details, the CoreWindow is the class that interop with the Windows Operating System and the UWP application model. It provides those functions such as the window size, location, the input status, etc. The Window is the class that provides the ability to use XAML UI for the window, such as setting the XAML content of the window, setting the titlebar of the window, or getting the Compositor of the window. The CoreApplicationView is the class that interop with the Windows Operating System and provides the mechanism of windows message loop and the ability to change the client area and the non-client area. The ApplicationView is the same as the Window, provides the ability to use XAML UI for the application.

In conclusion, the CoreWindow and the CoreApplicationView provide the low-level core functions of the operating system and the application model. The Window and the ApplicationView encapsulates them for XAML usage.

Some usages of these concepts

I’ve written some other posts about UWP that take advantages of these concepts. Unfortunately, they are all not in English.


本文会经常更新,请阅读原文: https://blog.walterlv.com/post/core-application-window-of-uwp-en.html ,以避免陈旧错误知识的误导,同时有更好的阅读体验。

如果你想持续阅读我的最新博客,请点击 RSS 订阅,或者前往 CSDN 关注我的主页

知识共享许可协议 本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可。欢迎转载、使用、重新发布,但务必保留文章署名 吕毅 (包含链接: https://blog.walterlv.com ),不得用于商业目的,基于本文修改后的作品务必以相同的许可发布。如有任何疑问,请 与我联系 ([email protected])