WPF - prevents ListBox items from being selected
This is almost a duplicate question. You are actually asking two questions here:
-
Make the style
ListBoxItem
not show highlighting (look elsewhere on SO for this answer) or replaceListBox
withItemsControl
if you don't need other features thatListBox
. -
Bind the CheckCheck IsChecked property to the parent property
ListBoxItem.IsSelected
:<CheckBox IsChecked="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}, Path=IsSelected}" />
source to share
When your user tries (un) to check your checkboxes, then the element will become "active" in some way. And the focused style will be applied. As far as I know, there is no way to disable selection (because if you made your checkboxes it won't work), but you can override the focused (or selected) style of the list items.
source to share