I started developing a UWP XAML custom control using the new C++/WinRT language projection. I got the basic structure right, but I'm stuck when it comes to defining the TemplatePartAttribute
attribute. In C#, and even C++/CX, this is pretty much straightforward because the language has direct support for this.
Now in C++/WinRT, I assume I have to define the attribute on the runtimeclass
in the MIDL source, but I have no idea how to get that right. For example:
[Windows.UI.Xaml.TemplatePart(L"PART_Button", ???)]
runtimeclass CustomControl : Windows.UI.Xaml.Controls.Control
{
CustomControl();
/* … */
}
While the Name
property of the TemplatePartAttribute
is easy to set because it's a String
, how do I set the Type
property - the three ??? - (which is a TypeName
in the Windows Runtime)? I didn't find any documentation about this, neither in the official C++/WinRT docs, nor the MIDL 3.0 ones.
EDIT (WORKAROUND):
It seems that the TemplatePart
attribute is not required to use the template part in code (using the GetTemplateChild()
method), I can get a reference to the element PART_Button
anyways.