I am learning to use Grid and I have three doubts in my project that even in the tests or the accompanying tutorials I did not get good results in practice since I always saw tests being done with BoxView:
HorizontalOption
basically I would only have 3 controls ( Start
, Center
and End
), and this is bad for me since I usually use more; but if using Margin
would not the spacing be different depending on the amount of megapixel in the screen of the tested device, so it could be good in my device but in another deformed?
BoxView
in the Grid to separate the lines from ListView
and get a better view, but I can not and will leave the code to help me if possible. Label Data:
that does not even appear in ListView
, I would like to know the reason. Picture of how is my project:
XAML:
<StackLayout><ListViewx:Name="lstCompra"
BackgroundColor="LightGray"
HasUnevenRows="True">
<!-- HasUnevenRows = Serve para fazer com que o conteúdo digitado não seja cortado -->
<ListView.ItemTemplate>
<!-- DataTemplate = exibe dados de uma coleção de objetos em um ListView -->
<DataTemplate>
<ViewCell>
<Grid>
<!-- Colunas -->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="180"/>
</Grid.ColumnDefinitions>
<!-- Linhas -->
<Grid.RowDefinitions>
<RowDefinition Height="15"/>
<RowDefinition Height="3"/>
</Grid.RowDefinitions>
<!-- Código -->
<Label Grid.Row="0"
Grid.Column="0"
Text="Código:"
FontSize="Small"
BackgroundColor="Yellow"
Margin="2, 0, 0, 0"/>
<Label Grid.Row="0"
Grid.Column="0"
Text="{Binding ID_SOLCOMPRA}"
FontSize="Small"
BackgroundColor="Green"
TextColor="Black"
Margin="50, 0, 0, 0"/>
<!-- Data -->
<Label Grid.Row="0"
Grid.Column="1"
Text="Data:"
FontSize="Small"
BackgroundColor="LightCyan"
HorizontalOptions="EndAndExpand"/>
<Label Grid.Row="0"
Grid.Column="1"
Text="{Binding DT_CADASTRO}"
FontSize="Small"
BackgroundColor="Fuchsia"
TextColor="Black"
HorizontalOptions="End"/>
<!-- Repartir conteudo com cor -->
<BoxView Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="1"
BackgroundColor="Red"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>