The ComboBox allows the user to select an item from a drop-down list or optionally to enter new text in the text box of the control.
The IsEditable and IsReadOnly properties specify how the ComboBox behaves when the user does one of the following:
Enters a string to select an item in the ComboBox.
Enters a string that does not correspond to an item in the ComboBox.
Selects part of the string that is in the text box.
Copies or pastes a value into the text box.
The following table describes the actions the user can and cannot take, depending on the values of IsEditable and IsReadOnly.
|
IsReadOnly is true |
IsReadOnly is false |
|---|
IsEditable is true | Cannot select an item in the ComboBox by entering a string. Cannot enter a string that does not correspond to an item in the ComboBox. Can select part of the string in the ComboBox text box. Can copy the string in the ComboBox text box, but cannot paste a string into the ComboBox text box.
| Can select an item in the ComboBox by entering a string. Can enter a string that does not correspond to an item in the ComboBox. Can select part of the string in the ComboBox text box. Can copy or paste the string in the ComboBox text box.
|
IsEditable is false | Can select an item in the ComboBox by entering a string. Cannot enter a string that does not correspond to an item in the ComboBox. Cannot select part of the string in the ComboBox. Cannot copy or paste the string in the ComboBox.
| Can select an item in the ComboBox by entering a string. Cannot enter a string that does not correspond to an item in the ComboBox. Cannot select part of the string in the ComboBox. Cannot copy or paste the string in the ComboBox.
|
The IsReadOnly property has an effect only if IsEditable is true.
The ComboBox is an ItemsControl, so it can display content other than simple strings. For example, you can create a ComboBox that contains a list of images. When you have content other than strings in the ComboBox, a nonsensical string might appear in the ComboBox when the drop-down list is hidden. To display a string in the ComboBox when it contains non-string items, use the TextSearch..::.Text or TextSearch..::.TextPath attached property.
Content Model: ComboBox is a ItemsControl. Its content properties are Items and ItemsSource. For more information on the content model for ComboBox, see Controls Content Model Overview.
Dependency properties for this control might be set by the control’s default style. If a property is set by a default style, the property might change from its default value when the control appears in the application. The default style is determined by which desktop theme is used when the application is running. For more information, see Themes.