I need create a custom combobox control that allows header as separator which should not be selectable using the mouse move or key press.
this is example:
Header1
item1
item2
item3
Header2
item4
item5
I tried many solutions, without success. Thanks in advance!
Once again, WPF can easily provide solutions that would require tons of horrible hacks in winforms.
Copy and paste my code in a File -> New Project -> WPF Application in Visual Studio.
You will quickly notice that my solution not only provides a different visual appearance for Header Items, but it also prevents unwanted selection, be it via mouse or keyboard, and it doesn’t need to subclass the regular ComboBox class, which would lead to lesser maintainability.
XAML:
Code Behind: