How can I unselect item in ListView?

后端 未结 8 986
故里飘歌
故里飘歌 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

    0 讨论(0)
  • 2021-01-08 01:58

    this is easier.

    this.myListView.SelectedIndex = -1;
    this.myListView.Update();
    
    0 讨论(0)
提交回复
热议问题