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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:33:51+00:00 2026-05-25T11:33:51+00:00

I have a very simple class public class SimpleClass // abreviated for this example

  • 0

I have a very simple class

public class SimpleClass // abreviated for this example
{
    public bool HighAlert {get;set;}
    public bool LowAlert  {get;set;}
    // about 10 other bools
 }

They are all boolean prorties. I could also use a struct or possibly an array if that makes things easier.

I’d like to databind to a listbox AND have the items that are “true” highlighted in blue or red. And of course have the listbox updated when my object instantiated from SimpleClass changes. My only other requirement is to have something in the list box other than the member names. For example, it might be nice to have “Low Bank Account Alert” rather than “LowAlert”.

And of course, the more this is automated (listbox actually using the SimpleClass) the better, for that inevitable day when someone adds a property to SimpleClass.

Any examples or tutorials? I would think this is a fairly common scenario.

Thanks,

Dave

  • 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-25T11:33:52+00:00Added an answer on May 25, 2026 at 11:33 am

    you question seems to be twofold.

    1) Conditional Formatting. you can use Triggers on the your list box, like this:

    <Style x:Key="ColoringStyle" TargetType="{x:Type ListBoxItem}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=HighAlert}" Value="True">
                    <Setter Property="Background" Value="#33FF0000"></Setter>
                </DataTrigger>
                <DataTrigger Binding="{Binding Path=LowAlert}" Value="True">
                    <Setter Property="Background" Value="#33FFDD00"></Setter>
                </DataTrigger>
    
            </Style.Triggers>
        </Style>
    

    2) Displaying ListBox items differently. in WPF, you can use ItemTemplate:

    <ListBox.ItemTemplate>
          <DataTemplate>
            <StackPanel Orientation="Horizontal">
                  --- Have your custom display in here ---- 
            </StackPanel>
          </DataTemplate>
        </ListBox.ItemTemplate>
    

    both are widely used, pls google for any detailed examples, hope you got the gist

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

Sidebar

Related Questions

I have a very simple class public class Preferences { public bool RepeatInfinite {
I have a simple class that provides state codes like this: public class StateProvider
This a data binding question in C#. I have a simple Person class: public
Very simply put: I have a class that consists mostly of static public members,
I have a very simple class with only one field member (e.g. String). Is
I have very simple select like this: SELECT * FROM table WHERE column1 IN
So I have a very simple class that has a method called getThumbUrl() but
I have a very simple class named person which is given below , I
If I have a simple class setup like this: class MyClass { private string
I have very simple situation and really don't have a clue why this isn't

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.