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:
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.UI, or split them into
CoreApplicationView manage the application model, and the
Window manage the application inner UI. The
CoreWindow manages the core functions, but the
Window manage the XAML UI.
From top to bottom is from
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?
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
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
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.
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
CoreWindow while the inner part contains
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.
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.
I’ve written some other posts about UWP that take advantages of these concepts. Unfortunately, they are all not in English.
- Create a UWP application from zero.
- Show multiple views for a UWP application
- Extends the titlebar of a UWP application
本文会经常更新，请阅读原文： https://blog.walterlv.com/post/core-application-window-of-uwp-en.html ，以避免陈旧错误知识的误导，同时有更好的阅读体验。