Say I have this class:
public ref class Page1 sealed : Windows::UI::Xaml::Controls::Page {};
I can activate an instance of this class like this:
auto page = ref new Page1();
But how would I do that in raw C++?
I have tried this but it doesn't work:
Microsoft::WRL::Wrappers::HString className;
className.Set(L"App1.Page1");
IInspectable *page;
Windows::Foundation::ActivateInstance(className.Get(), &page);
The above code does work when I specify a windows runtime class name, (such as "Windows.UI.Xaml.Controls.Button"), just not my own ref class "App1.Page1".
Alternatively, given that I have declared a public ref class named Page1
in the App1
namespace, how can I activate an instance of this class as an IInspectable*
from the HSTRING "App1.Page1"?