How to unselect selected item of a combo box?

aindrea

Member
Joined
Jun 5, 2018
Messages
23
Programming Experience
1-3
I have grappled with WPF-applications, and there is one thing that I could not glean from the documentation:

If I have a WPF-Window with a Combo Box „comboBoxCars“ where the user can select, say some cars. I thereafter added a button „clearAll“, and as soon as that button is clicked, the following method is called:

C#:
         private void OnButtonClick(object sender, RoutedEventArgs e)
        {
 
            //comboBoxCars how to unselect all previously selected items?
                 . . .          
             
        }

I would like to unselect any item in the comboBoxCars. How can I achieve this? If I simply write comboBoxCars.Items.Clear(); then there will be nothing left to select. Is there something like „unselect all“ or something similar?
 
Last edited:
Thanks! After all, I did it as follows. I added an empty element by dint of whose index I set it again as soon as the "clear" button is clicked.
 
Back
Top Bottom