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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:53:29+00:00 2026-05-25T22:53:29+00:00

I have a combobox filled with a list of Objects. I like to highlight

  • 0

I have a combobox filled with a list of Objects. I like to highlight an item in a combobox based on a IsHighlighted property of the Object.

I’ve tried writing my own style but no real success…

<Style x:Key="SimpleComboBoxItem" TargetType="ComboBoxItem">
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBoxItem">
                    <Border Name="Border" Padding="2" SnapsToDevicePixels="true">
                        <ContentPresenter x:Name="contentPresenter" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="#FFCCCCCC"/>
                        </Trigger>
                        <Trigger Property="Tag" Value="Highlight" SourceName="contentPresenter">
                            <Setter Property="Background" TargetName="Border" Value="#FFAAF3A0"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

Thanx in advance

  • 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-25T22:53:29+00:00Added an answer on May 25, 2026 at 10:53 pm

    This should work fine with a simple DataTrigger.

    Your Object Class:

    public class TestObject
    {
        public string Name { get; set; }
    
        public bool IsHighlighted { get; set; }
    
        public override string ToString()
        {
            return this.Name;
        }
    }
    

    Xaml:

    <Window x:Class="TestWPF.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:local="clr-namespace:TestWPF"
            Title="MainWindow">
        <Grid>
            <StackPanel>
                <ComboBox>
                <ComboBox.Resources>
                    <Style TargetType="ComboBoxItem">
                        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                        <Setter Property="Background" Value="Gray" />
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding IsHighlighted}" Value="True">
                                <Setter Property="Background" Value="Red" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </ComboBox.Resources>
                    <local:Employee Name="Nick" />
                    <local:Employee Name="Bob" IsHighlighted="True" />
                    <local:Employee Name="Fred" />
                </ComboBox>
            </StackPanel>
        </Grid>
    </Window>
    

    Note: Unlike the sample above, I’m guessing in your code you’re binding the combobox’s ItemsSource… which should work just the same. One thing to be careful of though, is if your object’s ‘IsHighlighted’ property can change, you should be implementing INotifyProperty changed to ensure that changing the value will notify the UI that the triggers should refresh.

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

Sidebar

Related Questions

I have ComboBox . When I click on item from expanded list, ComboBox select
I have a combobox that is filled with data field JobCode from database. There
I have a combobox in a WPF Window, it is filled with usernames from
I've got a problem with VB6. I have a form with several ComboBox objects
I have a Silverlight application with a ComboBox that is filled by VideoCaptureDevice 's.
I have a ComboBox filled with a custom Class called TableHeader, this class contains
The problem is strange, I have a combobox which is correctly filled with items
In my WPF application, I have a ComboBox that is filled with a static
I have DataGridView which contains two ComboBox columns. The second ComboBox will be filled
I have a Property Grid in C#, loading up a 'PropertyAdapter' object (a basic

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.