WPF: ComboBox with reset item

后端 未结 9 1918
长发绾君心
长发绾君心 2020-12-15 23:33

I want to make a ComboBox in WPF that has one null item on the top, when this gets selected, the SelectedItem should be set to null (reset to default state). I\

9条回答
  •  [愿得一人]
    2020-12-15 23:56

    It is possible to reset the selection if you select an item.

    
        
            
                
                    
                        
                            
                                
                                    
                                
                            
                                                       
                    
                
            
            First Item
            Second Item
        
    
    

    Unfortunately this will not work with ItemsSource and a CompositeCollection to add this reset item to an arbitrary list. The reason is WPF can't resolve the Storyboard.TargetName in this scope. But maybe this helps you go on with retemplating the ComboBox.

提交回复
热议问题