c++windows-runtimeuwp-xamlc++-cxc++-winrt

No instance of overloaded function winrt::Windows::UI::Xaml::Controls::Primitives::SelectorItem::Content matches the argument list


In C++/CX, I was able to do:

Windows::UI::Xaml::Controls::Primitives::SelectorItem item;
const wchar_t* str = L"someString";
item->Content = str;

But, when I do the equivalent in C++/WinRT,

winrt::Windows::UI::Xaml::Controls::Primitives::SelectorItem item;
const wchar_t* str = L"someString";
item.Content(str);

I get an error:

No instance of overloaded function winrt::Windows::UI::Xaml::Controls::Primitives::SelectorItem::Content matches the argument list.

What am I missing?


Solution

  • The Content function expects something of type IInspectable, wchar_t is this not though. If you pass "primitives", you need to box them. The following works:

    winrt::Windows::UI::Xaml::Controls::Primitives::SelectorItem item;
    const wchar_t* str = L"someString";
    item.Content(box_value(str));