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

Deselect selected item of ListView

$
0
0

Hi, I want to deselect already selected item by click. So the user first clicks an item and it becomes selected, then user clicks same item once again and it should become deselected. Following code doesn't work, the item is still shown as selected, however Selected property of ListView is null.

list.ItemTapped += (sender, e) => {
    if(e.Item == null) return;

    if(selectedItem == e.Item)
    {
        ((ListView)sender).SelectedItem = null;

        selectedItem = null;
    }
    else{
        selectedItem = e.Item;
    }
}; 

Viewing all articles
Browse latest Browse all 77050

Trending Articles



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