uwp - 构建创建 UWP cppwinrt SolidColorBrush 时出错

标签 uwp c++-winrt

为文本 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/

相关文章:

c# - FolderPicker 无故立即关闭

asynchronous - UWP/WinRT 与 C++/CX : In a chain of asynchronous tasks, 如何在它们之间传递数据?

c++ - co_await 表达式需要 await_ready 函数

c# - Windows.AI.MachineLearning.Preview - 从流中加载模型引发异常

visual-studio - 错误 : this template attempted to load component assembly 'Microsoft. VisualStudio.Universal.TemplateWizards,版本=15.0.0.0

c# - UWO 电子邮件消息换行/换行?

c# - UWP 在代码隐藏中设置主题资源丙烯酸

c# - Android和iOS不异步时如何处理UWP异步?

windows-runtime - 如何使用midlrt.exe将.idl编译为.winmd?