Henok De

Henok De

  • NA
  • 6
  • 602

WPF PreviewTextInput one character behind

Jul 29 2023 10:03 PM

I am working on an application configuration UI. I would like detect a category that is entered into the textbox, so that I may proceed to show the user a drop down with the specific values for that category. I am using a PreviewTextInput event for the textbox to detect what is being entered. The issue is that my method is not being hit until the user enters an extra character.

For example: I want to show specific values when if (textBox.Text == "Algorithm"), but PreviewTextInput only makes this conditional true, when another character after the "m" is entered. I need this to work properly because I will be using JSON to check the categories and their specific values.

I have presented code that shows this issue at a basic level

if (textBox.Text == "Algorithm")
{
    ValueList.Add("Pixel");
    ValueList.Add("O2")
}

 


Answers (1)