Forum Cross Platform with Xamarin
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

how reference ItemTappedEventArgs with stacklayout

In a stacklayout within a datatemplate of a list I want to get the id of the item that I select from the stacklayout



  • suraj007suraj007 Member ✭✭✭

    private string selectedItem;

    private void MyCategory_ItemSelected(object sender, SelectedItemChangedEventArgs e)
    var selectedCategory = e.SelectedItem as Catergory; /////Catergory is list model name.

    if (selectedCategory != null)
        selectedItem = selectedCategory.Id;


  • LandLuLandLu Member, Xamarin Team Xamurai

    Register the ItemTapped of your listview:

    <ListView ItemsSource="{Binding Items}" ItemTapped="ListView_ItemTapped">

    You can access the item in the event:

    private void ListView_ItemTapped(object sender, ItemTappedEventArgs e)
        var model = (Model)e.Item;
        // Get the ID here
  • Ashish_sharmaAshish_sharma INMember ✭✭✭
    edited October 2019

    You have to create Stack-layout tap-gesture Event and when u tap on any item then u get id of selected items .

Sign In or Register to comment.