There is a combobox:

<ComboBox Name="MyBox" SelectedIndex="0" FontSize="20"> <ComboBoxItem>-</ComboBoxItem> </ComboBox> 

Here is how it is filled:

 public void FillComboBox() { foreach (var res in list) MyBox.Items.Add(res.Name); } 

It is necessary that when the window opens, the SelectedItem property in the ComboBox is an item with Name = "Ivan". Plus make ComboBox ReadOnly. Those. so that from it it was impossible to choose anything.

  • 3
    What did you try? Asked yourself SelectedItem? Found the property ReadOnly? - tym32167
  • I tried to assign SelectedItem in this way: MyBox.SelectedItem.Equals (index); where index is the received index list through the lambda expression. But still nothing is assigned. And the IsReadOnly property is programmatically like this: MyBox.IsReadOnly = true; why it doesn’t work - kornilovyvan
  • one
    Почему так не работает: StationsBox.IsReadOnly = true;? what does not mean? Can you then select any item in the combo box? - tym32167
  • one
    In general, to block the whole combo box, specify cb.IsEnabled = false; . The IsReadOnly and IsEditable refer to the ability to write text in a combo box, and do not touch the opportunity to select any element. - tym32167

0