[ACCEPTED]-Setting Column Background in WPF ListView/Gridview-styles

Accepted answer
Score: 17

Set the HorizontalContentAlignment of the ItemContainerStyle:

<ListView ItemsSource="{Binding}">
    <ListView.ItemContainerStyle>
        <Style TargetType="ListViewItem">
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        </Style>
    </ListView.ItemContainerStyle>
</ListView>

Result:

alt text

0

Score: 5

Digging up an old thread, but I found a 5 dodgy fix for this

<Grid Background="{Binding backGround}" Margin="-6,0,-6,0">
  <TextBlock Margin="6,0,6,0" Text="{Binding myText}" TextAlignment="Right" />
</Grid>

Moves the margins so the 4 background color fills the entire cell, but 3 then moves them back so the text is still 2 in the right spot. Works for now until 1 it's fixed properly.

More Related questions