문제

Users will usually expand the ComboBox, pick the desired option and the ComboBox will hide other options. Now user can delete the chosen option by pressing backspace button. May I know how to prevent it?

도움이 되었습니까?

해결책

This could be avoided by handling the PreviewKeyDown event and marking any use of the backspace key as handled

void OnComboPreviewKeyDown(object sender, KeyEventArgs e) { 
  if (e.Key == Key.Back) { 
    e.Handled = true;
  }
}

다른 팁

You could set its DropDownStyle to DropDownList if you don't want it to be editable at all.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top