hugo
hugo

Reputation: 475

Xamarin forms refresh listview to tap an item many times

I am learning Xamarin, I have a listview with Items "A","B","C".

When I click on one Item I got a display alert that says Item "A was tapped". When I click again on Item A nothing happen but something happens if I tap the Item "B" or "C" ("B was tapped" or "C was tapped")

My question is, how can refresh my listview in order to tap waterver I want the Item A ?

I have used Device.BeginInvokeOnMainThread(() => }); but it is not helping

Here is the code :

 public void ListviewLanguageRefresh1()
        {

       
                var dictionary = keys.Zip(values, (k, v) => new { Key = k, Value = v })
                   .ToDictionary(x => x.Key, x => x.Value);  // contaning Items A,B,C

            Device.BeginInvokeOnMainThread(() =>
            {

                //Trying to refresh the listview
                ListViewlingueelanguages.ItemsSource = dictionary;
            });

           
        }

Upvotes: 0

Views: 130

Answers (1)

Jason
Jason

Reputation: 89082

from the docs

  • ItemSelected fires when a new item is selected.
  • ItemTapped fires when an item is tapped.

You didn't actually post the code you are using for "tapped" but I assume you are using ItemSelected. You can either switch to ItemTapped, or clear the SelectedItemproperty in your ItemSelected handler

Upvotes: 1

Related Questions