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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:04:24+00:00 2026-05-26T06:04:24+00:00

This one has been bugging me for a while and I cant seem to

  • 0

This one has been bugging me for a while and I cant seem to get it to work. I am using a Data Template to format items within a ListBox control, like so:

<ListBox HorizontalAlignment="Stretch" Name="listBox1" VerticalAlignment="Stretch" Grid.ColumnSpan="3" Grid.Row="1">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="30" />
                    <ColumnDefinition Width="30" />
                    <ColumnDefinition Width="100*" />
                </Grid.ColumnDefinitions>
                <Rectangle Width="30" Height="10" Grid.Column="0" 
                    VerticalAlignment="Stretch" 
                    HorizontalAlignment="Stretch" 
                    Fill="{Binding Path=Color, 
                        Converter={StaticResource SolidColorBrushConverter}, 
                        Mode=OneWay}" />
                <CheckBox Grid.Column="1" 
                    VerticalAlignment="Center" 
                    HorizontalAlignment="Center" 
                    IsChecked="{Binding Path=Selected}" />
                <Label Grid.Column="2" VerticalAlignment="Center" 
                    Content="{Binding Path=Name}" />
            </Grid>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

The problem is that the rectangle does not appear with the bound color, as it should. Tracing the converter, the binding seems to get the color correctly from the bound item (the other bindings on the checkbox and the label work as expected). Also I get no binding errors in the debug output.

I also tried wrapping the rectangle in a <border> element with a black border, which shows correctly, so I know the rectangle is at least showing up, however replacing the BorderBrush attribute with the same binding from the rectangle’s Fill attribute as shown above causes the border to disappear (again, with no binding errors).

How does one correctly achieve binding of a Color in WPF?

  • 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-26T06:04:25+00:00Added an answer on May 26, 2026 at 6:04 am

    Nothing wrong with that code, the fault has to be with the converter. Maybe it gets the color but sets the alpha channel to 0, making all colors fully transparent. If that is not it you should post the code of the converter so people can have a look at it.

    Also you can easily get by without any converters:

    <Rectangle.Fill>
        <SolidColorBrush Color="{Binding Color}"/>
    </Rectangle.Fill>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This one has been bugging me for a while now, but I never seem
This one has been bugging me for a while now. Is there a way
This has been bugging me for a while and I'm hoping that one of
This is one thing that has been bugging me for a while about DDD.
This one has been stumping me for a while. But I'm no expert. This
This is a strange one that has been bugging me today. Due to the
I know this one has been asked before, however I can't seem to find
This problem probably has been discussed, but this one is slightly different. I'm using
This has been bugging me for the past several hours and I can't seem
This has been bugging me for a while. I have this ircbot that I

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.