Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How to get the id of the toggled switch item in the listview?

$
0
0

I have a listview and all the listview item contain a switch at the right end like below picture.

When I select an item the switch fires the Toggled event. My codes are adding below:

Xaml:

     <Switch
           Toggled="OnToggledEvent"
           HorizontalOptions="EndAndExpand"
           VerticalOptions="CenterAndExpand"/>

Xaml.cs:

void OnToggledEvent(object sender, ToggledEventArgs args)
    {
        //How I can access the userId of the selected item
    }

Model class:

public class DirectoryResponse
    {
        public List<UserProfileHBList> userProfileHBList { get; set; }
    }

    public class UserProfileHBList
    {
        public UserProfileTO userProfileTO { get; set; }
    }

    public class UserProfileTO
    {
        public string userId { get; set; }
        public string firstName { get; set; }
        public string email { get; set; }
        public string lastName { get; set; }
    }

I need the userId of the selected item, how I can access that.
Thanks in advance :smile:


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>