async void OnItemSelected(object sender, EventArgs e) { BindableObject layout = (BindableObject)sender; PokeType pokeType = (PokeType)layout.BindingContext; await pokeType.LoadStrengths(); TypeDetailViewModel typeDetailViewModel = new TypeDetailViewModel(pokeType); await Navigation.PushAsync(new TypeDetailPage(typeDetailViewModel)); }
// Convert Type public TypeDetailViewModel ConvertType(CarType type) { // Get a list of cars var carlist = new List <CarDetailViewModel>(); // But only set them if there are any carlist.AddRange(type.Cars?.Select(ConvertCar)); // Set values to detail view var vm = new TypeDetailViewModel { Id = type.Id, Brand = type.Brand, Model = type.Model, Cars = carlist }; return(vm); }
public TypeDetailPage(TypeDetailViewModel viewModel) { InitializeComponent(); BindingContext = this.viewModel = viewModel; }