<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TestDrive"
x:Class="TestDrive.MainPage">
<ListView ItemsSource="{Binding Veiculos}" Margin="25"
ItemTapped="ListView_OnItemTapped">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Horizontal">
<Label Text="{Binding Nome}" FontSize="20"
VerticalTextAlignment="Center">
</Label>
<Label Text=" - "
VerticalTextAlignment="Center">
</Label>
<Label Text="{Binding PrecoFormatado}" FontSize="Bold"
VerticalTextAlignment="Center">
</Label>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentPage>
namespace TestDrive
{
public class Veiculo
{
public string Nome { get; set; }
public decimal Preco { get; set; }
public string PrecoFormatado => $"R$ {Preco}";
}
public partial class MainPage : ContentPage
{
public List<Veiculo> Veiculos { get; set; }
public MainPage()
{
InitializeComponent();
var mainPage = this;
mainPage.Veiculos = new List<Veiculo>
{
new Veiculo {Nome = "Veloster", Preco = 1000},
new Veiculo {Nome = "Fusca", Preco = 60000},
new Veiculo {Nome = "Uno", Preco = 20000}
};
BindingContext = mainPage.Veiculos;
}
Existe alguma restrição do List no Xamarin?