1
I am learning to use Grid and I have three questions in my project that even in tests or when following tutorials did not get good results in practice since I always saw being tested with Boxview:
- What is the best way to give space between components? Why use
HorizontalOptionbasically I would have only 3 controls (Start,CenterandEnd), and this is bad for me since I usually use more; but if I useMarginit would not be different the spacing depending on the amount of megapixel on the screen of the tested appliance, thus being able to look good in my appliance but in another deformed? - I want to use a
BoxViewon the Grid to separate lines from theListViewand get a better view, but I’m not getting it and I’ll leave the code to, if possible, help me. - When viewing the code it will be clear that I use a
Label Data:that does not even appear in theListView, would like to know the reason.
Image of how my project is going:
XAML:
<StackLayout>
<ListView x: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>
