Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9147091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:54:14+00:00 2026-06-17T10:54:14+00:00

I am using WinRT XAML. I am trying to create my own HirarchicalDataTemplate in

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:54:15+00:00Added an answer on June 17, 2026 at 10:54 am

    The WinRT version of DataTemplate does not have a public Template property. The ContentProperty is specified as Template, so I tried changing that:

    [ContentProperty(Name = "MyTemplate")]
    

    However the error persists: the code generation tries to add an entry for the Template property all the same, from XamlTypeInfo.g.cs:

    userType.AddMemberName("MyTemplate");
    userType.AddMemberName("Template");
    

    To use a different content property, we can either use a non DataTemplate subclass and define both Template and ItemTemplate of type DataTemplate; or continue to subclass DataTemplate, implement a dummy Template property, and use a separate MyTemplate property to host the actual content template. That might be usable at a push, but can’t allow the template to be used in a DataTemplate type property.

    Trying to get a DataTemplate subclass to work, I tried adding a Template property of object type:

    public class HierarchicalDataTemplate : DataTemplate
    {
        public object Template
        {
            get { return (object)GetValue(TemplateProperty); }
            set { SetValue(TemplateProperty, value); }
        }
        public static readonly DependencyProperty TemplateProperty =
            DependencyProperty.Register("Template", typeof(object), typeof(HierarchicalDataTemplate), new PropertyMetadata(null));
        // ItemTemplate...
    }
    

    This works in the Visual Studio designer, but not at runtime:

    <local:HierarchicalDataTemplate x:Key="t1">
        <TextBlock Text="SUCCESS" />
    </local:HierarchicalDataTemplate>
    

    From FrameworkTemplate docs:

    FrameworkTemplate has a ContentPropertyAttribute that indicates that its XAML content property is named “Template”. FrameworkTemplate doesn’t define a property of that name, nor do its derived types that have a practical usage (ControlTemplate, DataTemplate). The content of a FrameworkTemplate is a root element that should be created when the template is applied, and isn’t a conventional property in the object model. Content of a FrameworkTemplate is handled specially by the XAML parser when content is created from a template.

    It doesn’t look too hopeful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How I can create bitmap image from xaml control using WritableBitmapEx. In my winRT
How do I create DataTemplate in win8 (WinRT) App using code behind file i.e.
When I create a winrt component using WRL, the problem is that I can
I am using a WinRT client. I receive this exception when I try to
My WinRT XAML page loads an image from a file asset like this: Image
I'm using OAuth to authenticate a user in my WinRT application (C#/XAML). All works
I'm trying to create an ImageToggleButton for my WinRT project that changes it's image
Has anyone been able to add primitives in XAML in WinRT? I'm trying to
I'm using the SharpDX Toolkit, and I'm trying to create a Texture2D programmatically, so
Can we use NuGet packages in developing WinRT Metro style applications using XAML/C# or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.