What's the difference between CoreApplicationView, CoreWindow, and ApplicationView ?
I can see that each has different properties etc. of the app so I'm not asking "which one should I use to get the abc
property or method?".
I am asking what's the logical difference between them. Why have different classes? Since they seem to be more or less the same thing - a class representing the app window.
There are several differences between the classes you mention. We can distinguish them by two dimensions:
I've written a post especially for this question, see http://walterlv.github.io/post/core-application-window-of-uwp-en.html.
Sometimes we have to view the full class names with namespaces to determine their meanings.
Windows.ApplicationModel.Core.CoreApplication
Windows.ApplicationModel.Core.CoreApplicationView
Windows.UI.Xaml.Application
Windows.UI.Core.CoreWindow
Windows.UI.Xaml.Window
Extra, if you're interested in the titlebar,
Windows.ApplicationModel.Core.CoreApplicationViewTitleBar
Windows.UI.ViewManagement.ApplicationViewTitleBar
Extra, if you're interested in the threading model,
Windows.UI.Core.CoreDispatcher
Windows.UI.Xaml.DispatcherTimer
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 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
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With