How can I unselect item in ListView?

后端 未结 8 982
故里飘歌
故里飘歌 2021-01-08 01:19

I have a ListView with a couple of items in it. When the ListView looses focus, the last selected ListViewItem is still \"selected\" with a gray background.
I would like

8条回答
  •  花落未央
    2021-01-08 01:53

    You can try it:

    MyList.ItemSelected += (sender, e) => {
        ((ListView)sender).SelectedItem = null;
    };
    

    or if you have the OnSelection created in your View code behind(xaml.cs):

     private void OnSelection(object sender, SelectedItemChangedEventArgs e)
            {
               ((ListView)sender).SelectedItem = null;
            }
    

    Regards

提交回复
热议问题