为文本 block 创建实心画笔 (cppwinrt) 时出现错误,使用:
void MainPage::myStyle(Controls::TextBlock & block)
{
block.FontSize(72.0);
block.Foreground(Media::SolidColorBrush(Windows::UI::Colors::Orange()));
block.VerticalAlignment(VerticalAlignment::Center);
}
error: LNK2019 unresolved external symbol "public: __thiscall winrt::Windows::UI::Xaml::Media::SolidColorBrush::SolidColorBrush(struct winrt::Windows::UI::Color const &)"
当我取出 solidbrush 时出现错误,我也尝试过其他版本的 solidbrush 出现相同的错误。
最佳答案
你需要
#include <winrt/Windows.UI.Xaml.Media.h>
使用来自命名空间 winrt::Windows::UI::Xaml::Media
的类型.这记录在 Get started with C++/WinRT 下:
Whenever you want to use a type from a Windows namespaces, include the corresponding C++/WinRT Windows namespace header file, as shown. The corresponding header is the one with the same name as the type's namespace. For example, to use the C++/WinRT projection for the Windows::Foundation::Collections::PropertySet runtime class,
#include <winrt/Windows.Foundation.Collections.h>
.
关于uwp - 构建创建 UWP cppwinrt SolidColorBrush 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53022168/