Reputation: 166
This is a very novice question (new to coding), but I have an object that's been passed through a method as an argument. I want to get the highlighted value and use it as a variable (So I can in turn pass it on to another piece of code)
I'd quite like to be able to get all the properties from the "Item" node. These are all mapped in the Race object model.
How can I do this?
The code I currently have is this but it doesn't actually return the right data somehow.
async void Handle_ItemTapped(object sender, SelectedItemChangedEventArgs e)
{
if (e.SelectedItem == null)
return;
var race = e.SelectedItem as Race;
var raceid = race.Id;
await Navigation.PushAsync(new RaceView());
//Deselect Item
((ListView)sender).SelectedItem = null;
}
Upvotes: 0
Views: 576
Reputation: 6872
Simply change the handler signature to:
async void Handle_ItemTapped(object sender, Xamarin.Forms.ItemTappedEventArgs e)
Then you can use e.Item?.Id
to manipulate the value.
Upvotes: 3