I'm sorry my English isn't very good. I have a class like this
struct WrapPanel :winrt::Windows::UI::Xaml::Controls::PanelT<WrapPanel>
{
public:
WrapPanel(std::nullptr_t) {};
// other code.....
}
Use in other classes
WrapPanel wrapPanel{ ItemsPanelRoot().try_as<WrapPanel>()};
//Error C2440 'initializing': cannot convert from 'initializer list' to 'WrapPanel'
like: https://learn.microsoft.com/en-us/windows/uwp/cpp-and-winrt-apis/move-to-winrt-from-cx Converting from a base runtime class to a derived one
If you author a runtime class in C++/WinRT, you'll get several classes with the same name in different namespaces. Let's suppose that there's a namespace named NS1
, in which there's a runtime class called WrapPanel
, you'll get winrt::NS1::WrapPanel
, winrt::NS1::implementation::WrapPanel
and winrt::NS1::factory_implementation::WrapPanel
. The first one is the "projection" of the runtime class, which we usually use; the second one is the "implementation", which implements the runtime class; the third one is the "factory", which is used by module.g.cpp
.
If you convert a base class to a derived one, you should use the "projection". It seems that you have used the "implementation".