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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:11:00+00:00 2026-05-11T07:11:00+00:00

When a user clicks on an ListBoxItem, I want to it to be a

  • 0

When a user clicks on an ListBoxItem, I want to it to be a bold larger font red background yellow

Everything works except the background. It seems that there is a standard (blue) background for the selected item. How do I override that and change the selected background yellow?

Here is the code:

<Window x:Class='AlternateListBox2.Window1'     xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'     xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'     Title='Window1' Height='300' Width='300'     xmlns:local='clr-namespace:AlternateListBox2'>     <Window.Resources>         <local:Countries x:Key='countries'/>         <Style TargetType='{x:Type ListBoxItem}'>             <Setter Property='Content' Value='{Binding Path=Name}'/>             <Setter Property='Margin' Value='2'/>             <Style.Triggers>                 <Trigger Property='IsSelected' Value='True'>                     <Setter Property='FontWeight' Value='Bold'/>                     <Setter Property='FontSize' Value='18'/>                     <Setter Property='Background' Value='Yellow'/>                     <Setter Property='Foreground' Value='Red'/>                 </Trigger>             </Style.Triggers>          </Style>     </Window.Resources>     <StackPanel>         <ListBox             ItemsSource='{Binding Source={StaticResource countries}}'             Width='100'             Margin='10'             HorizontalAlignment='Left'             />     </StackPanel> </Window> 
  • 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-11T07:11:00+00:00Added an answer on May 11, 2026 at 7:11 am

    It can be done a lot simpler. The Background color for the selected ListBox items are taken from the SystemColors. So, what you need to do is override the SystemColors in the Resources of your ListBox:

    <ListBox.Resources>     <!--Selected color when the ListBox is focused-->     <SolidColorBrush x:Key='{x:Static SystemColors.HighlightBrushKey}' Color='Yellow' />     <!--Selected color when the ListBox is not focused-->     <SolidColorBrush x:Key='{x:Static SystemColors.ControlBrushKey}' Color='Yellow' /> </ListBox.Resources> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When user clicks hyperlink on my ASP.NET page, I want a new browser to
When user clicks on select box , I want to hide the options menu
When a user clicks a submit button I want the form to be submitted.
I want to bind a user control (View) to a ListBoxItem. The ListBox is
I want to run some code when the user single clicks on any given
A user clicks on a row of a table, and I want to get
When the user clicks on this element, I want it to show an alert.
When the user clicks the My Notifications tab, I want him to see a
When a user clicks the SHow me more button in my app, I want
If a user clicks on a button that does a post (lets say it

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.