0

This is part of my window: MyListBox. I would like the space between the items to be green as well (if the upper and lower item is green) but I don't know how to change it.

This is my XAML code (tried to put the background colour in the StackPanel but nothing changed):

<ListBox Background="LightCyan" Name="MondayListBox">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Background="{Binding backgroundColor}">
                                <TextBlock Text="{Binding Time, StringFormat={}{0:hh}:{0:mm}}" Background="{Binding BackgroundColor}"/>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>

Any suggestion would be very appreciated.

EDIT: I setted the backgorundColor to be a Brushand initialized it with Brushes.LightCyan but I still have the white spaces between the items.

Asia Lucchi
  • 101
  • 2
  • 10

1 Answers1

0

Where is backgroundColor coming from? Are you sure that it's a Brush object, as required for Control.Background, rather than just a Color value?

You can use a ValueConverter class, such as in this answer to convert from one to the other.

Peregrine
  • 3,766
  • 3
  • 14
  • 34