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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T02:00:15+00:00 2026-05-13T02:00:15+00:00

alt text http://akashkava.com/blog/wp-content/uploads/2009/12/ListBoxItem-Selection-Problem.png The following code, behaves little strange. <ListBox SelectionMode=Multiple> <StackPanel> <TextBlock>Selection is

  • 0

alt text http://akashkava.com/blog/wp-content/uploads/2009/12/ListBoxItem-Selection-Problem.png

The following code, behaves little strange.

<ListBox SelectionMode="Multiple">

        <StackPanel>
            <TextBlock>Selection is Black</TextBlock>
        </StackPanel>

        <ListBoxItem>
            <StackPanel>
                <TextBlock>Selection is White</TextBlock>
            </StackPanel>
        </ListBoxItem>
</ListBox>

Note that first selection stays in black color, that is because the Item is not its own ItemContainer, however in 2nd case Item is its own ItemContainer so the style works correctly. Majority of time we populate data through templates and everytime our Item is not its own ItemContainer and thats why TextBlock behaves strange with respect to foreground color.

Important: I am looking for the answer to “Why this happens” not how to solve it, I know the workaround TextElement.Foreground=”{TemplateBinding Foreground}”, but I want to know why this is happening.

  • 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-13T02:00:15+00:00Added an answer on May 13, 2026 at 2:00 am

    I guess, that’s because the logical trees are different here:

    alt logical tree http://img13.imageshack.us/img13/9082/logicaltree.jpg

    When you explicitly specify ListBoxItem you add it to the logical tree, and Foreground is inherited from it. In case with StackPanel, logical tree is different, and Foreground is inherited from different parent… I’m sure you’ve read this before, but just for the log. There is really great article from Mike Hillberg: Of logical and visual trees in WPF. He explains this behavior very clearly.

    Cheers

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

Sidebar

Related Questions

alt text http://blog.chomperstomp.com/img/wikipediaGoogle.png How can I get a search box like this listed for
I have following scenario: alt text http://static.zooomr.com/images/7579022_e64808b855_o.png We have a WebService which poses as
alt text http://sites.google.com/site/yanchengcheok/Home/help-remove-dot-line.png?attredirects=0 Whenever a click event happen on a hyper-link, I will use
alt text http://www.freeimagehosting.net/uploads/e9ab873d56.png Look at the bottom component where GroupBox is Open Work Orders.
alt text http://www.freeimagehosting.net/uploads/b350914deb.png i want to retrieve the list of user and local service
alt text http://www.freeimagehosting.net/uploads/abbcae9cd3.png I want to create a listbox like the one shown in
alt text http://www.freeimagehosting.net/uploads/a96118564f.png In above image, You can see the numbers on the pin.
Regarding the SMS compose view as show in the picture below: alt text http://www.kennethlund.dk/wordpress/wp-content/uploads/2008/08/iphone_sms.jpg
alt text http://barbarosalp.com/questions/list.png Hi, As you can see on the picture above i have
alt text http://home.elka.pw.edu.pl/~pkolodzi/Capture.PNG I have created the IAdder interface with two methods: PassA and

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.