WPF ComboBox, force input to UpperCase

后端 未结 4 1191
孤城傲影
孤城傲影 2021-01-20 05:45

I have an editable WPF ComboBox with TextSearchEnabled. I need to force the user\'s text input to uppercase when they type to filter the ComboBox.

I was thinking of

4条回答
  •  不知归路
    2021-01-20 06:38

    This works and seems like a reasonable solution:

    protected void winSurveyScreen_Loaded(object sender, RoutedEventArgs e)
    {
        (comboBox.Template.FindName("PART_EditableTextBox", cbObservation) as TextBox).CharacterCasing = CharacterCasing.Upper;
    }
    

    Ensure that the combobox is not collapsed on loaded otherwise the template will not be found.

提交回复
热议问题