I'm writing an app with ListView
defined below:
<ListView x:Name="TodosRecibos">
<ListView.HeaderTemplate>
<DataTemplate>
<Grid Padding="12" Background="Transparent">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.75*"/>
<ColumnDefinition Width="1.5*"/>
<ColumnDefinition Width="3.5*"/>
<ColumnDefinition Width="3.75*"/>
<ColumnDefinition Width="0.5*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Recibo" Style="{ThemeResource BodyTextBlockStyle}" FontWeight="Bold"/>
<TextBlock Grid.Column="1" Text="Data" Style="{ThemeResource BodyTextBlockStyle}" FontWeight="Bold"/>
<TextBlock Grid.Column="2" Text="Tomador" Style="{ThemeResource BodyTextBlockStyle}" FontWeight="Bold"/>
<TextBlock Grid.Column="3" Text="Serviço" Style="{ThemeResource BodyTextBlockStyle}" FontWeight="Bold"/>
<TextBlock Grid.Column="4" Text="Valor" Style="{ThemeResource BodyTextBlockStyle}" FontWeight="Bold"/>
</Grid>
</DataTemplate>
</ListView.HeaderTemplate>
<ListView.ItemTemplate>
<DataTemplate x:Name="ListaRecibos" x:DataType="data:Recibo">
<Grid Height="48" AutomationProperties.Name="{x:Bind ReciboId}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.75*"/>
<ColumnDefinition Width="1.5*"/>
<ColumnDefinition Width="3.5*"/>
<ColumnDefinition Width="3.75*"/>
<ColumnDefinition Width="0.5*"/>
</Grid.ColumnDefinitions>
<TextBlock VerticalAlignment="Center" Text="{x:Bind ReciboId}"/>
<TextBlock Grid.Column="1" VerticalAlignment="Center" Text="{x:Bind ServicoData}"/>
<TextBlock Grid.Column="2" VerticalAlignment="Center" Text="{x:Bind TomadorNome}"/>
<TextBlock Grid.Column="3" VerticalAlignment="Center" Text="{x:Bind ServicoDescricao}"/>
<TextBlock Grid.Column="4" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{x:Bind ServicoValor}"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
I expected items in ListView
to follow column spacing set to ListView.HeaderTemplate
, identical to ListView.ItemsTemplate
. However, when executing, the items look like this:
How can I make items in ListView
correctly align to columns?