I am using WinRT XAML. I am trying to create my own HirarchicalDataTemplate in WinRT. I inherited my class from DataTemplate.
public class HierarchicalDataTemplate : DataTemplate
{}
But when I try to initialize a new HierarchicalDataTemplate in my Page resources, it shows following error on compilation.
HierarchicalDataTemplate does not contain a definition for ‘Template’.
Any ideas how to resolve.
The WinRT version of
DataTemplatedoes not have a publicTemplateproperty. TheContentPropertyis specified asTemplate, so I tried changing that:However the error persists: the code generation tries to add an entry for the
Templateproperty all the same, from XamlTypeInfo.g.cs:To use a different content property, we can either use a non
DataTemplatesubclass and define bothTemplateandItemTemplateof typeDataTemplate; or continue to subclassDataTemplate, implement a dummyTemplateproperty, and use a separateMyTemplateproperty to host the actual content template. That might be usable at a push, but can’t allow the template to be used in aDataTemplatetype property.Trying to get a
DataTemplatesubclass to work, I tried adding aTemplateproperty ofobjecttype:This works in the Visual Studio designer, but not at runtime:
From FrameworkTemplate docs:
It doesn’t look too hopeful.