Loading string resources from WinUI 3 C++/WinRT
See the question and my original answer on StackOverflowWith WinUI 3, most namespaces usually start with Microsoft
, instead of Windows
(which was more for UWP).
It's actually difficult to get to the WinUI3-only documentation, here is some: Manage resources with MRT Core
The WinUI 3 resource entry point is now the Microsoft.Windows.ApplicationModel.Resources.ResourceManager class.
So, for a "MyString" string resource in a "Resources.resw" file
You can now do this:
Microsoft::Windows::ApplicationModel::Resources::ResourceManager rm{};
auto str = rm.MainResourceMap().GetValue(L"Resources/MyString").ValueAsString();
Note that you need to #include <winrt/Microsoft.Windows.ApplicationModel.Resources.h
> after Xaml includes to compile.