Some of the items in my ListBox use a template that contains a button and a TextBox. How can I make it such that it is impossible to select these items from the list, but still possible to interract with the button?
EDIT:
I still need to be able to select other items in this list, just not ones with this template.
We can use a attached property to the ListBoxItem (after I implemented I found someone who had done almost the same) :
The xaml:
The viewmodel:
The only caveat with this approach is that trying to select an unselectable item unselects the current selected one if the ListBox has single selection, or unselects all, if the ListBox has extended selection.