I have two pages created in Xamarin.forms
, on the first page I have a list and on the second the details of each item selected previously. I send the selected item from the first page to the second through the communication of the two code behind .
Page where I have the list (Code Behind):
private async void ListViewCats_ItemSelected(object sender, SelectedItemChangedEventArgs e)
{
var SelectedCat = e.SelectedItem as Models.Cat;
if (SelectedCat != null)
{
await Navigation.PushAsync(new Views.DetailsPage(SelectedCat));
ListViewCats.SelectedItem = null;
}
}
Code Behind page:
Cat SelectedCat;
public DetailsPage(Cat selectedCat)
{
this.SelectedCat = selectedCat;
}
In this way I can display the data of this object normally in xaml
. But I want to pass this value selectedCat
to the ViewModel
of details I created, how can I do this?