【问题标题】:Errors on build creating a UWP cppwinrt SolidColorBrush构建创建 UWP cppwinrt SolidColorBrush 时出错
【发布时间】:2018-10-28 00:10:18
【问题描述】:

为文本块创建实心画笔 (cppwinrt) 时,我在构建时遇到错误,使用:

void MainPage::myStyle(Controls::TextBlock & block)
{   
    block.FontSize(72.0);
    block.Foreground(Media::SolidColorBrush(Windows::UI::Colors::Orange()));
    block.VerticalAlignment(VerticalAlignment::Center);     
}   

错误:LNK2019 无法解析的外部符号“public: __thiscall winrt::Windows::UI::Xaml::Media::SolidColorBrush::SolidColorBrush(struct winrt::Windows::UI::Color const &)”

当我取出solidbrush时出现错误,我也尝试了其他版本的solidbrush,但出现相同错误。

【问题讨论】:

    标签: uwp c++-winrt


    【解决方案1】:

    你需要

    #include <winrt/Windows.UI.Xaml.Media.h>
    

    使用命名空间winrt::Windows::UI::Xaml::Media 中的类型。这记录在Get started with C++/WinRT:

    只要您想使用 Windows 命名空间中的类型,请包括相应的 C++/WinRT Windows 命名空间头文件,如图所示。相应的标头是与类型的名称空间同名的标头。例如,要将 C++/WinRT 投影用于 Windows::Foundation::Collections::PropertySet 运行时类,#include &lt;winrt/Windows.Foundation.Collections.h&gt;

    【讨论】:

      猜你喜欢
      • 2017-01-24
      • 2016-06-14
      • 2012-03-30
      • 2015-02-02
      • 2016-07-07
      • 1970-01-01
      • 2019-09-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多