I have a simple ListView inside of a grid which take the full page (see screenshow below). I was able to stretch the rows of the ListView to the full width of the container using a style (HorizontalContentAlignment), but I can’t do the same with the header. I’m not able to set the HorizontalContentALignement to Stretch for the Header (see highlighted in screenshot below).
Any idea how I could accomplish this?
<Page.Resources>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
</Page.Resources>
<Grid Grid.Row="1">
<ListView x:Name="itemListView" Margin="120,0,0,60" SelectionMode="None" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch">
<ListView.Header>
<Grid Margin="6" HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="Rank" Style="{StaticResource TitleTextStyle}" TextWrapping="NoWrap" />
<TextBlock Grid.Column="1" Text="Username" Style="{StaticResource TitleTextStyle}" TextWrapping="NoWrap" />
<TextBlock Grid.Column="2" Text="Score" Style="{StaticResource TitleTextStyle}" />
</Grid>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<Grid Margin="6" HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding Rank}" Style="{StaticResource TitleTextStyle}" TextWrapping="NoWrap" />
<TextBlock Grid.Column="1" Text="{Binding Username}" Style="{StaticResource CaptionTextStyle}" TextWrapping="NoWrap" />
<TextBlock Grid.Column="2" Text="{Binding Score}" Style="{StaticResource BodyTextStyle}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
