Though a ComboBox control is like ListBox, it does not show the list of items by default. A user intervention is required to display the items. The UI of a ComboBox is a combination of three controls:
- A TextBox, which displays the selected item
- A Button, which is used to show or hide available items
- A Popup, which displays a list of items inside a scrollable pane and gives the user the option to select one item from the available list
ComboBox contains a collection of ComboBoxItem. You can add those to its Items property. When you click on the arrow-head, the list of items will pop up in the screen, as demonstrated in the preceding screenshot. To preselect an item from code, set its IsSelected property to True.
You can also add custom contents to a ComboBoxItem to represent a better UI component. The second ComboBox in the preceding example, demonstrates how easy it is to customize the UI.
Just like ListBox, it also exposes SelectedItem, SelectedIndex, SelectedValue...