内容简介:I find a question on Stack OverflowThis post is written in
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.
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
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.
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.
- Create a UWP application from zero.
- Show multiple views for a UWP application
- Extends the titlebar of a UWP application
References
本文会经常更新,请阅读原文: https://walterlv.github.io/post/core-application-window-of-uwp-en.html ,以避免陈旧错误知识的误导,同时有更好的阅读体验。
本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可。欢迎转载、使用、重新发布,但务必保留文章署名 吕毅 (包含链接: https://walterlv.github.io ),不得用于商业目的,基于本文修改后的作品务必以相同的许可发布。如有任何疑问,请 与我联系 。
以上所述就是小编给大家介绍的《UWP CoreApplication/Application Vs CoreApplicationView/ApplicationView Vs CoreWindow/Window》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Web Analytics 2.0
Avinash Kaushik / Sybex / 2009-10-26 / USD 39.99
The bestselling book Web Analytics: An Hour A Day was the first book in the analytics space to move beyond clickstream analysis. Web Analytics 2.0 will significantly evolve the approaches from the fir......一起来看看 《Web Analytics 2.0》 这本书的介绍吧!