Disallow/Block selection of disabled combobox item in wpf

后端 未结 2 441
情深已故
情深已故 2020-11-30 10:01

I\'m writing an application wherein I would like to disable few items in the ComboBox and also want to disallow/block selection of disabled items. Please note C

2条回答
  •  旧时难觅i
    2020-11-30 10:21

    You can achieve this by setting IsEnabled property of a ComboBoxItem to false;

    So each item in ComboBox's ItemSource (i.e. Cars in your case) can be an object having some property (say IsSelectable) specifying whether it should be enabled or disabled and then use it with a style to make an item un-selectable. something like this -

     
    

    Update:

    
        
            
                
            
        
    
    

提交回复
热议问题