ComboBox::IsReadOnly Property
Gets or sets a value that enables selection-only mode, in which the contents of the combo box are selectable but not editable.
Assembly: PresentationFramework (in PresentationFramework.dll)
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 | ||
IsEditable is false |
When IsEditable is equal to false, the ComboBox uses a ContentPresenter to display the currently selected item; when IsEditable is equal to true, a TextBox is used for this purpose instead. Note that a TextBox only displays plain text, and that a ComboBoxItem may include non-plain text content, such as images.
Identifier field | |
Metadata properties set to true |
The following example shows a ComboBox with an editable TextBox. The IsReadOnly property is set to true, so the user cannot enter text into the TextBox.
<ComboBox Name="cb" Margin="10,10,3,3" Width="200" Height="30" Grid.Column="0" Grid.Row="2" ItemsSource="{StaticResource myCities}" Text="My Cities" IsEditable="true" IsReadOnly="true" IsDropDownOpen="True" StaysOpenOnEdit="True"> </ComboBox>
Available since 3.0