GetRuntimeClassName function (C++/WinRT)
A member function (of a generated implementation type) that returns a string containing the fully-qualified type name of the Windows Runtime class being implemented.
For an explanation of the implementation type and projected type concepts, see Consume APIs with C++/WinRT and Author APIs with C++/WinRT.
This is a member function of generated implementation types. To retrieve the runtime class name of any arbitrary IInspectable, use winrt::get_class_name. Also see the function that both methods are based on, which is IInspectable::GetRuntimeClassName.
Syntax
winrt::hstring GetRuntimeClassName() const;
Return value
A winrt::hstring containing the fully-qualified type name of the Windows Runtime class implemented by the implementation type.
Example
// MainPage.cpp
void winrt::MyProject::implementation::MainPage::f()
{
winrt::hstring name = GetRuntimeClassName();
assert(name == L"MyProject.MainPage");
}
You can implement ICustomPropertyProvider::Type like this.
Windows::UI::Xaml::Interop::TypeName Type()
{
return Windows::UI::Xaml::Interop::TypeName{ GetRuntimeClassName() };
};
Or you can use the winrt::xaml_typename function template.
Requirements
Minimum supported SDK: Windows SDK version 10.0.17134.0 (Windows 10, version 1803)
Tool: cppwinrt.exe