Search code examples
c#wpfcaliburn.microwpf-listview

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


Solution

  • 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
     }