Content Index Search
 

SimpleComboBox and SimpleComboBoxItem

The combo box is an items control in the form of a drop-down list. You can place content in a combo box in Microsoft® Expression Blend™ by double-clicking the combo box and then drawing an element (such as a SimpleComboBoxItem) within it. Alternatively, you can right-click the combo box under Objects and Timeline, and then click Add SimpleComboBoxItem to add individual items to the collection, or click Bind ItemsSource to Data to generate the collection of ComboBoxItem elements from a data source. To view the combo box on the artboard while it is expanded, you can right-click the combo box or combo box item under Objects and Timeline, and then click Expand ComboBox.

Artboard view: SimpleComboBox

The artboard view of a SimpleComboBox control after two items are added.

Breaking down the control template

The SimpleComboBox control template consists of the following items:

The SimpleComboBoxItem control template consists of the following items:

Objects view: The basic parts (template) of SimpleComboBox Objects view: The basic parts (template) of SimpleComboBox

Objects view: The basic parts (template) of a SimpleComboBox control (left) and a SimpleComboBoxItem control (right).

Property triggers used

Property triggers in the control template are used to make the control react to property changes. You can click the items under Triggers in the Interaction panel to view the properties that are changed when a trigger is active. For example, in the template for the combo box, when the HasItems property is False, the minimum height of the DropDownBorder element is set to 95 so that an empty drop-down window appears when the combo box is clicked. If the minimum height was set to 0, a very tiny drop-down window would appear. In the template for the combo box item, when the IsHighlighted property is True, the Background property of the Border element is changed to indicate which item in the combo box is selected.

Brushes used

The following brush resources in the SimpleStyles.xaml resource dictionary are used by the SimpleComboBox and SimpleComboBoxItem templates:

Best practices and design guidelines

Try it!