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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:24:11+00:00 2026-05-21T18:24:11+00:00

I am trying to create different themes for a custom PropertyGrid control that inherits

  • 0

I am trying to create different themes for a custom PropertyGrid control that inherits from TreeView, and uses TreeViewItems as the item containers. Additionally, I want to set the control template for the TreeViewItems based on the type of object the TreeViewItem is bound to. I would prefer to populate the PropertyGrid as I am now by setting ItemsSource.

Currently I am applying different control templates based on the type of bound object by setting the TreeViewItems.ItemContainerStyleSelector via a HierarchialDataTemplate. In this style selector I am returning a static resource via a resource key. I would like to not use this selector and resource key method, but rather create different derived TreeViewItem objects based on the type of the object it is to be bound to. This would allow me to apply a different style per theme based on type, in the same way that other controls are themed. But I don’t see a way to do this. The override ItemsControl.GetContainerForItemOverride would do what I want if it was passed the object to be bound to, or at least its type, but I don’t see a way to make this work. Any ideas on how to do this? Or, am I going about his all wrong?

  • 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-21T18:24:12+00:00Added an answer on May 21, 2026 at 6:24 pm

    Your best bet would be to add a read-only custom dependency property to your custom TreeViewItem. For lack of a better name, let’s call this “Look”. This property can then be an enumeration with the various looks or Styles you want applied.

    Then you can create a single Style for your custom TreeViewItem, which uses Style Triggers based on your Look property to change the Template or various other properties.

    You can then set your Look property in a PrepareContainerForItemOverride, based on the item that is given.

    The ItemsControl in general expect their “container” to be of a single type, but this isn’t strictly enforced. But as you said, you can’t create different containers based on the item it is wrapping.

    In addition, virtualization adds a bit of complexity to the mix. As in that case, containers may be reused so you would not have a chance to “create” a new one of the property type. But, even with virtualization enabled, the PrepareContainerForItemOverride will be called.

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

Sidebar

Related Questions

I'm trying to create a Control that basically allows me to draw different strings
I'm trying to create a string that has a set amount of different words
I have a C#/WPF app. I am trying to create different versions that will
I am trying to create a dynamic lambda expression (parsed from text), that does
I am trying to create 3 different lists (1,2,3) from 2 existing lists (A,B).
I am trying to create a UDF that does 2 different things depending on
I'm trying to create a menu, in which the last menu item (with different
I am trying to create two different sets of settings for datepicker( http://keith-wood.name/datepick.html )
I'm trying to create a database with 12 different tables which has been working
I'm trying to create a simple form with two different submit buttons: one which

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.