Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

make Listbox items in WPF not selectable

Tags:

wpf

listbox

I have a listbox in WPF, and when they select an item, it shows an ugly colors Can I make all the items non-selectable?

like image 478
Ghassan Karwchan Avatar asked Nov 12 '09 14:11

Ghassan Karwchan


2 Answers

Add Focusable property as false in ListBoxItem style:

<Style x:Key="{x:Type ListBoxItem}" TargetType="{x:Type ListBoxItem}">   <!-- Possibly other setters -->   <Setter Property="Focusable" Value="False" /> </Style> 
like image 23
Vadym Kyrylkov Avatar answered Nov 13 '22 06:11

Vadym Kyrylkov


If you don't need selection, use an ItemsControl rather than a ListBox

like image 120
Thomas Levesque Avatar answered Nov 13 '22 06:11

Thomas Levesque