1
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 the items in the ListView
followed the spacing of columns defined in ListView.HeaderTemplate
, identical in ListView.ItemsTemplate
. However, when executing, the items are like this:
How can I make the items in ListView
align correctly to the columns?
@Diegorafaelsouza is the default style without modifications.
– João Santana
I searched the API for this attribute, but only found it in Xamarin. Anyway, I found a solution.
– João Santana
Yes, I thought the components of UWP were the same used in Xamarin.Forms. It must be the same as WPF. + 1
– Diego Rafael Souza