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 880575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:07:15+00:00 2026-05-15T12:07:15+00:00

When I attempt to specify multiple DataTemplates for use by a ContentControl so that

  • 0

When I attempt to specify multiple DataTemplates for use by a ContentControl so that the correct one (based on Type) is used, I end up with Content that is simply the Content’s ToString() value.

<ContentControl DataContext="{Binding MyTreeRootViewModels}" Content="{Binding /, Path=CurrentlySelectedTreeViewModel}">
  <ContentControl.Resources>
     <DataTemplate DataType="x:Type vm:TypeAViewModel">
        <StackPanel>
           <local:TypeAUserControl />
           </StackPanel>
     </DataTemplate>

     <DataTemplate DataType="x:Type vm:TypeBViewModel">
        <StackPanel>
           <local:TypeBUserControl />
        </StackPanel>
     </DataTemplate>
  </ContentControl.Resources>
</ContentControl>

In the example above I would see MyApp.ViewModel.TypeAViewModel displayed when a tree node of TypeAViewModel is returned by CurrentlySelectedTreeViewModel. I expect to see my TypeAViewModelUserControl.

I’ve tried putting a single <TextBlock Text="TESTING"/> element in one of my data templates just to see if the problem was related to my user controls. Same result.

Any ideas what I am doing wrong?

(By the way, the CurrentlySelectedTreeViewModel is a property that returns the currently selected node in my TreeView. It seems to work just fine – as I select nodes in the tree, the correct type name for the node appears ContentControl).

  • 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-05-15T12:07:16+00:00Added an answer on May 15, 2026 at 12:07 pm

    The x:Type bit should be between curly braces {}:

    <DataTemplate DataType="{x:Type vm:TypeAViewModel}">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 497k
  • Answers 497k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Make sure the COM component you are accessing is registered. May 16, 2026 at 12:06 pm
  • Editorial Team
    Editorial Team added an answer Try defining the bean as lazy="true", so that it is… May 16, 2026 at 12:06 pm
  • Editorial Team
    Editorial Team added an answer I would suggest you to use the HTML Purifier for… May 16, 2026 at 12:06 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

In formal specifications based on abstract algebraic types and equational theory you use formulas
How would one implement a search field like the one used on the iPhone
I want to share a data with multiple processes. My first attempt is to
Possible Duplicate: How can I specify system properties in Tomcat configuration on startup? What
When using the Visual Studio shortcut/snippets is it possible to specify the collection in
I'd like to configure visual studio 2005 to copy .dll's based on whether the
This is my second attempt at a php contact form using Jquery and php
I have recently started using the -Wall compiler switch in an attempt to improve
I'm working on get my site validated in an attempt to iron out issues
I get an Class not registered error whenever I attempt to connect to the

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.