Ali
Ali

Reputation: 436

Wpf listview disable selection but allow clicking

I have a simple listview bound to data with caliburn micro. When i click an item an event happens but othe item gets the blue selection and unable to click it again (without clicking elsewhere then on it again). How can i allow selecting the same item twice without having to select another item first?

Note: All other questions on SO seem to answer how to remove the blue highlight, but my issue is with the behaviour not the style

Upvotes: 0

Views: 617

Answers (1)

Anu Viswan
Anu Viswan

Reputation: 18173

You could make use of MouseLeftButtonUp event. For example,

 <ListView ItemsSource="{Binding Data}" x:Name="MyListView" cal:Message.Attach="[Event MouseLeftButtonUp]=[Action OnClick($this)]"  />

And in View Model

 public void OnClick(object item)
 {
       if (item == null) return;
            // do something
 }

Upvotes: 1

Related Questions