Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I force a ListView to disregard clicking/not highlight a clicked item?

As I'm not processing the items in a ListView based on what a user may select (the processing always uses everything in the list), I want to disallow the selecting of an item which may make the user think he is limiting the processing to that one item (I've already got multiselect = false, so that's not an issue).

like image 327
B. Clay Shannon-B. Crow Raven Avatar asked Sep 28 '12 21:09

B. Clay Shannon-B. Crow Raven


1 Answers

There is not any property to disable item selection in the ListView.

What you can do is to handle the event that notifies that an item has been selected by attaching an event handler to ItemSelectionChanged and then deselect the item:

yourListView.ItemSelectionChanged += yourListView_ItemSelectionChanged;

private void yourListView_ItemSelectionChanged(
    object sender,
    ListViewItemSelectionChangedEventArgs e)
{
   if (e.IsSelected)
      e.Item.Selected = false;
}
like image 98
Adriano Repetti Avatar answered Sep 22 '22 15:09

Adriano Repetti