views:

249

answers:

1

I have a ComboBoxItem that acts strictly as a section title. Visually, I have it set but how do I eat the click when something is selected?

I would prefer to accomplish this in xaml, if possible. TIA

+1  A: 

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.

Ben Collier
That would give it the default disabled try (which I could work around) but it doesn't work if I've MouseOvered a live item. So, if I click the first item that is a title, no problem. If I MouseOver a live item -- thus selecting it -- and click on the title item it accepts the click on the live MouseOvered item. Could be my Styles and templates but I thought there might be a property... Thanks!
Brad
'Default Disabled LOOK'
Brad
Interesting. Perhaps there is something happening with the style, relating to the Select-on-MouseOver functionality (it doesn't do this with the default style). A possible solution for that problem would be to handle the PreviewMouseDown event on the title item and cancel the click. This might require some work in code behind, though.
Ben Collier
Thaks, I give it a go.
Brad
Not my day for typing!
Brad