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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:30:16+00:00 2026-05-11T14:30:16+00:00

I have an object of Type MyTypeOneViewModel that is displayed in the first column

  • 0

I have an object of Type MyTypeOneViewModel that is displayed in the first column of ListView and I have an object of Type MyTypeTwoViewModel that is displayed in the 2nd column of my ListView. Both types have a property of type MyNestedViewModel. Now I would like to display a different DataTemplate for each cell in the ListView depending on the actual Type of that Property. For example if the property actually holds a MyDoubleNestedViewModel I want to display a Textbox in that cell and if that property holds a MyBooleanNestedViewModel I want to display a ComboBox in that particular cell of the ListView. Note that The DataTemplate could vary in each row and column.

Can I achieve this without a TemplateSelector? WPF is able to autmatically chose the right DataTemplate based on the bound Type. But does that work in this nested scenario in a ListView too somehow?

  • 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. 2026-05-11T14:30:17+00:00Added an answer on May 11, 2026 at 2:30 pm

    Consider these options:

    1. Bind directly to the sub-property.

    Bind the column to the sub-property (of type MyNestedViewModel) rather than the parent. WPF will then pick a template based on the type of the nested view model, rather than the type of the parent view model.

    <GridViewColumn DisplayMemberBinding='{Binding TheChildViewModel}'/> 

    2. Include a ContentControl in your cell template.

    In your grid column templates, bind a ContentControl to the child property:

    <GridViewColumn.CellTemplate>     <DataTemplate>         <StackPanel>             <Label Content='{Binding SomePropertyOnParentViewModel}'/>             <ContentControl Content='{Binding TheChildViewModel}'/>         </StackPanel>     </DataTemplate> </GridViewColumn.CellTemplate> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 collections of objects. the objects have an object-type 'key' property (I
I have an object of type Hash that I want to loop over via
I have an object of type CGPDFDictionaryRef returned somehow from a method that is
I have an object of type 'numpy.ndarray', called myarray, that when printed to the
Suppose you have an object of type BlahChild that is an extension of BlahParent,
I have a certain object type that is stored in a database. This type
I have created an object type.. and after initilializing I am pushing that into
I have a situation where I have an object of type dynamic that is
If I have an object of type Person and it has a navigation property
I have people object and poeple have property group that make them belong to

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.