jvdh
jvdh

Reputation: 308

How to get TypeName of underlying type in in C++/WinRT?

I'm trying to implement the ICustomPropertyProvider::Type() method, however I can't find a way to get TypeName of a C++/WinRT type. Apparently you have Object::GetType and T::typeid in C++/CX, but not in C++/WinRT.

I tried the following code, but that was just a wild guess as it was the only thing I could find that has remotely to do with types. I presume typeid() has nothing to do with XAML however, since the only guarantee it gives is that the string it returns is uniquely identifying.

using namespace Windows::Devices::Enumeration;
using namespace Windows::UI::Xaml::Interop;

TypeName name;
name.Name = typeid(DeviceInformation).name();
name.Kind = TypeKind::Metadata;

Upvotes: 3

Views: 1185

Answers (1)

Kenny Kerr
Kenny Kerr

Reputation: 3115

The winrt::xaml_typename<Type>() function template is what you're after.

Upvotes: 5

Related Questions