Content Index Search
 

SimpleListBox and SimpleListBoxItem

The list box is an items control in the form of a scrollable list. You can place content in a list box in Microsoft® Expression Blend™ by double-clicking the list box and then drawing an element (such as a rectangle) into it. Alternatively, you can right-click the list box under Objects and Timeline, and then click Add SimpleListBoxItem to add individual items to the collection, or click Bind ItemsSource to Data to generate the collection of SimpleListBoxItem elements from a data source. If you add individual items to the collection, you can reorder the items by double-clicking the list box to make it active, and then dragging the items to change them to the desired order. You can set which item is selected by using the SelectedIndex property of the list box.

Artboard view: SimpleListBox after two items are added

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

Breaking down the control template

The SimpleListBox control template consists of the following items:

The SimpleListBoxItem control template consists of the following items:

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

Objects view: The basic parts (template) of a SimpleListBox control (left) and a SimpleListBoxItem 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 list box, when the IsSelected property of a list box item is True, the background color of the item is changed. In the template for the list box item, when the IsHighlighted property is True, the Background property of the Border element is changed to indicate which item in the list box is selected.

Brushes used

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

Best practices and design guidelines

Try it!