Este artigo foi traduzido por máquina. Para visualizar o arquivo em inglês, marque a caixa de seleção Inglês. Você também pode exibir o texto Em inglês em uma janela pop-up, movendo o ponteiro do mouse sobre o texto.
Tradução
Inglês

Propriedade ComboBox.IsEditable

 

Obtém ou define um valor que habilita ou desabilita a edição do texto na caixa de texto do ComboBox.

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (em PresentationFramework.dll)

public bool IsEditable { get; set; }

Valor da Propriedade

Type: System.Boolean

true se o ComboBox puder ser editado; caso contrário, false. O padrão é false.

The P:System.Windows.Controls.ComboBox.IsEditable and P:System.Windows.Controls.ComboBox.IsReadOnly properties specify how the T:System.Windows.Controls.ComboBox behaves when the user does one of the following:

  • Enters a string to select an item in the T:System.Windows.Controls.ComboBox.

  • Enters a string that does not correspond to an item in the T:System.Windows.Controls.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 P:System.Windows.Controls.ComboBox.IsEditable and P:System.Windows.Controls.ComboBox.IsReadOnly.

IsReadOnly is true

IsReadOnly is false

IsEditable is true

  • Cannot select an item in the T:System.Windows.Controls.ComboBox by entering a string.

  • Cannot enter a string that does not correspond to an item in the T:System.Windows.Controls.ComboBox.

  • Can select part of the string in the T:System.Windows.Controls.ComboBox text box.

  • Can copy the string in the T:System.Windows.Controls.ComboBox text box, but cannot paste a string into the T:System.Windows.Controls.ComboBox text box.

  • Can select an item in the T:System.Windows.Controls.ComboBox by entering a string.

  • Can enter a string that does not correspond to an item in the T:System.Windows.Controls.ComboBox.

  • Can select part of the string in the T:System.Windows.Controls.ComboBox text box.

  • Can copy or paste the string in the T:System.Windows.Controls.ComboBox text box.

IsEditable is false

  • Can select an item in the T:System.Windows.Controls.ComboBox by entering a string.

  • Cannot enter a string that does not correspond to an item in the T:System.Windows.Controls.ComboBox.

  • Cannot select part of the string in the T:System.Windows.Controls.ComboBox.

  • Cannot copy or paste the string in the T:System.Windows.Controls.ComboBox.

  • Can select an item in the T:System.Windows.Controls.ComboBox by entering a string.

  • Cannot enter a string that does not correspond to an item in the T:System.Windows.Controls.ComboBox.

  • Cannot select part of the string in the T:System.Windows.Controls.ComboBox.

  • Cannot copy or paste the string in the T:System.Windows.Controls.ComboBox.

When P:System.Windows.Controls.ComboBox.IsEditable is equal to false, the T:System.Windows.Controls.ComboBox uses a T:System.Windows.Controls.ContentPresenter to display the currently selected item; when P:System.Windows.Controls.ComboBox.IsEditable is equal to true, a T:System.Windows.Controls.TextBox is used for this purpose instead. Note that a T:System.Windows.Controls.TextBox only displays plain text, and that a T:System.Windows.Controls.ComboBoxItem may include non-plain text content, such as images.

Identifier field

IsEditableProperty

Metadata properties set to true

None

The following examples create T:System.Windows.Controls.ComboBox controls that contain images as items instead of text. If the P:System.Windows.Controls.ComboBox.IsEditable property is set to true, the T:System.Windows.Controls.TextBox displays the value returned by the image's M:System.Object.ToString method. To avoid a T:System.Windows.Controls.TextBox with unexpected text, use the P:System.Windows.Controls.TextSearch.Text and P:System.Windows.Controls.TextSearch.TextPath properties to assign text to be displayed.

<ComboBox IsEditable="true" TextSearch.TextPath="Name">
  <Image Name="Cat" Source="data\cat.png"/>
  <Image Name="Dog" Source="data\dog.png"/>
  <Image Name="Fish" Source="data\fish.png"/>
</ComboBox>
<ComboBox IsEditable="true">
  <Image TextSearch.Text="Cat" Source="data\cat.png"/>
  <Image TextSearch.Text="Dog" Source="data\dog.png"/>
  <Image TextSearch.Text="Fish" Source="data\fish.png"/>
</ComboBox>

Another solution is to use the P:System.Windows.Controls.ItemsControl.DisplayMemberPath property. The drop-down control of the T:System.Windows.Controls.ComboBox will not display the images but will display the text you assigned.

The following example shows how to use P:System.Windows.Controls.ItemsControl.DisplayMemberPath.


<ComboBox IsEditable="true" DisplayMemberPath="Name">
  <Image Name="CAT" Source="data\cat.png"/>
  <Image Name="DOG" Source="data\dog.png"/>
  <Image Name="FISH" Source="data\fish.png"/>
</ComboBox>

.NET Framework
Disponível desde 3.0
Silverlight
Disponível desde 2.0
Windows Phone Silverlight
Disponível desde 7.0
Retornar ao início
Mostrar: