Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a focus to an editable ComboBox in WPF

I am using an editable ComboBox in wpf but when i try to set focus from C# code, it is only shows selection. but i want to go for edit option (cursor should display for user input).

like image 315
Raj Avatar asked Jun 03 '10 05:06

Raj


1 Answers

You can try this code:

        var textBox = (comboBox.Template.FindName("PART_EditableTextBox", comboBox) as TextBox);
        if (textBox != null)
        {
            textBox.Focus();
            textBox.SelectionStart = textBox.Text.Length;
        }
like image 168
Rikker Serg Avatar answered Oct 11 '22 16:10

Rikker Serg