Replies: 2 comments 1 reply
-
The two curious things about this are:
If you do not believe this, you can find all of this information in the metadata (.winmd files). These are viewable with ildasm and this comes with the .NET stuff in the Windows SDK. What's more, the documentation does state that Windows.UI.Colors and Windows.UI.ColorHelper are usable from desktop applications. Or rather doesn't state that it is unusable with the implication that all are usable unless stated otherwise. So, for the direct answer, there doesn't need to be a Microsoft.UI.Color and the WinUI team apparently decided to use the existing Windows.UI.Color. I appreciate that this can cause confusion though, especially with the prevailing "stuff in the UWP namespaces can only be used in UWP applications" that persists even now. This has never been true. Initially, Microsoft did try to use the DualApiPartition attribute to mark things which were usable from desktop applications, but as Windows evolved and the concept of desktop application changed, this became more difficult. There are also things in the UWP namespaces that can only be used from desktop applications too. As an example, the DesktopWindowTarget runtime class can be used to enable composition on a Windows API HWND and only a Windows API HWND. |
Beta Was this translation helpful? Give feedback.
-
It is confusing. This was the thinking behind it ... There's two SDKs: the Platform SDK (ships with the OS) and the App SDK (ships on nuget.org and Microsoft Store). We took many APIs in the Platform SDK and put them in the WinAppSDK, including much of the Windows.UI namespace. We didn't move Color because it's used by types that are only in the Platform SDK, such as media & clipboard APIs (e.g. DataPackagePropertySet). We also didn't see any benefit to moving Color, because we don't intend to ever change it anyway. We did foresee updating Colors and ColorHelper though over time, which is why that did get put into the WinAppSDK. The key unfortunate confusion this creates is that now there's motivation to have using statements in your code for both Windows.UI and Microsoft.UI, which creates a conflict with a few things such as WindowId in the Platform SDK and WindowId in WinAppSDK. |
Beta Was this translation helpful? Give feedback.
-
I came across the colors confusion today. See https://mariusbancila.ro/blog/2022/04/08/unwrapping-winui3-for-cpp/ for someone else's experience.
Why isn't there a microsoft::ui::color living in the same namespace as fromargb and colors?
Beta Was this translation helpful? Give feedback.
All reactions