This combobox should display a bound value as its text, and cannot be disabled. I just want to prevent a user from changing the displayed value.
ComboBox. SelectedIndexChanged Event (System.
We can Enable or Disable the options in the given Combobox widget by providing the state property. The state property forces to make a widget either active or disabled. To disable the Combobox widget, we have to set the state property as readonly or disabled.
On button click event handler, we add the content of TextBox to the ComboBox by calling ComboBox. Items. Add method. Now if you enter text in the TextBox and click Add Item button, it will add contents of the TextBox to the ComboBox.
comboBoxName.IsHitTestVisible = false; comboBoxName.Focusable = false;
Use these two line codes together.
Edit Note: Edited to solve the problem described by skypecakes
Accoring to MSDN you need
IsReadOnly = true;
IsEditable = false;
See http://msdn.microsoft.com/en-us/library/system.windows.controls.combobox.isreadonly.aspx under Remarks
Edit: actually, I'm not sure any more
I suggest using a style to set ReadOnly to true on PART_EditableTextBox
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With