I\'m looking to set the background of a column in a WPF GridView. Many Google results have pointed towards setting the GridViewColumn.CellTemplate to change the appearance o
Set the HorizontalContentAlignment
of the ItemContainerStyle
:
<ListView ItemsSource="{Binding}">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ListView.ItemContainerStyle>
</ListView>
Result:
Digging up an old thread, but I found a 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 background color fills the entire cell, but then moves them back so the text is still in the right spot. Works for now until it's fixed properly.