简体   繁体   中英

Is it possible to highlight the unselectable item in the list box on mouse hover?

I created a list box with item templates and linked it to a list below is a simplified version of it. These items are now selectable and highlight on mouse hover but I want to make them unselectable. if I change the focusable property in style to false then it is not highlighted on mouse hover.

<ListBox x:Name="ListBox1" x:Uid="ListBox1" 
  ItemsSource="{Binding myList}">
  <ListBox.ItemTemplate>
  .
  .
  .
  </ListBox.ItemTemplate>  
</ListBox>

The easiest way would be to add a PreviewMouseDown handler and return true to prevent them from being clicked on. They would still be selectable with the keyboard though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM