How do I listen to text changed events in a ComboBox in editable mode?

Platform: WPF| Category: ComboBox

Unfortunately, the first version of WPF does not provide a TextChanged event for a ComboBox like the one available for a TextBox. So, a workaround like the following is required:

[C#]

public Window1()
{
    InitializeComponent();
    this.comboBox.Loaded += delegate
    {
        TextBox editTextBox = comboBox.Template.FindName('PART_EditableTextBox', comboBox) as TextBox;
        if (editTextBox != null)
        {
            editTextBox.TextChanged += delegate { MessageBox.Show(comboBox.Text); };
        }
    };
}

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.