How to prevent selection with a list of items from your list in wpf?

This combobox must display the associated value as its text and cannot be disabled. I just want the user not to change the displayed value.

+2


source to share


5 answers


    comboBoxName.IsHitTestVisible = false;
    comboBoxName.Focusable = false;

Use these two line codes together.



Edit Note. Edited to address the issue described byskypecakes

+3


source


According 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 anymore

I suggest using style to set ReadOnly to true in PART_EditableTextBox

+1


source


Try XAML

IsEnabled="False"

      

FROM#

YOUCOMBOBOX.IsEnabled=false;

      

0


source


If you set IsEnabled = false this should work. In your XAML it will look like

<ComboBox IsEnabled="False"></ComboBox>
      

Run codeHide result


0


source


Your question is not clear.

The combo box has a dependency property IsEditable and if set to false the selected item cannot be edited. By default, this value is incorrect.

If you are talking about items in a combobox popup, then it should also be "non-editable" unless you changed your combobox data template to contain a list of text boxes that will cause the list to allow everyone to edit.

-2


source







All Articles