开发者

WPF disable click on ComboBoxItem

开发者 https://www.devze.com 2022-12-13 17:54 出处:网络
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 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号