WPF disable click on ComboBoxItem
I have a ComboBoxItem that acts strictly as a section title. Visually, I have it set but how do开发者_如何学Go I eat the click when something is selected?
I would prefer to accomplish this in xaml, if possible. TIA
You should be able to accomplish this by using the 'IsEnabled' property on the ComboBoxItem. In my quick test, this:
<ComboBox>
<ComboBoxItem>Item1</ComboBoxItem>
<ComboBoxItem IsEnabled="False">Item2</ComboBoxItem>
<ComboBoxItem>Item3</ComboBoxItem>
</ComboBox>
Results in a ComboBox with 3 items, and "Item2" does not get selected when clicked.
精彩评论