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

  • Home
  • SEARCH
  • 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 8142685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:53:42+00:00 2026-06-06T12:53:42+00:00

Let me explain you my situation. I have a base class called Shape, and

  • 0

Let me explain you my situation.

I have a base class called Shape, and several concrete classes like Triangle, Square, etc.

I have several data templates.

I’m building just one object. So I wouldn’t use an ItemControl control, I would like to use a normal panel like the grid, and show the respective data template (in DataContext has the concrete item)..

The only way to do this is using an ItemsControl? Or there’s another way.. because I’m just using one item and not a collection and display the correct template.

  • 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-06T12:53:43+00:00Added an answer on June 6, 2026 at 12:53 pm

    DataTemplates are used in much more than just ItemsControls

    They are used to tell WPF how to draw any object in the Visual Tree. For example, if you stick a User class object in the VisualTree, a DataTemplate can be used to tell WPF how to draw that User object

    They are most frequently used in controls with an ItemsSource or Content properties, because those are the most common way of inserting data objects into the VisualTree.

    In your specific case where you only want to insert one data item into the VisualTree, I would suggest a ContentControl

    <ContentControl Content="{Binding MyDataObject}" />
    

    To tell WPF how to draw MyDataObject you can either use the ContentTemplate property and set it to a DataTemplate

    <ContentControl Content="{Binding MyDataObject}" 
                    ContentTemplate="{StaticResource MyDataTemplate}" />
    

    or define an implicit DataTemplate that tells WPF to draw any object of a specific type using a specific template.

    <DataTemplate DataType="{x:Type local:MyDataObject}">
        <!-- Tell WPF how to draw MyDataObject here -->
    </DataTemplate>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

let me explain my current situation i have a SharePoint site lets say it
First let me explain. I have several addresses on the page that I put
Let me explain the situation before I ask the question. I have a site,
Let me explain my situation. I have made a user control that contains an
Let me explain my situation, I have a list of checkboxes in a fieldset,
Let me explain the situation I have two tables: -One is to store the
Let me explain my situation. Currently, I have a lot of applications running on
Imagine I have a situation where I need to index sentences. Let me explain
Let me explain ;-) both classes below are in package com.company.foo RoleGroup.scala abstract class
I know the question sound's a bit weird. Let me explain the situation: I

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.