autocompletebox focus in wpf

前端 未结 7 1734
無奈伤痛
無奈伤痛 2020-12-20 15:57

when I try to focus on my \"autocompletetextbox\" I failed I write autocompletetextbox.focus() but the cursor still focus in another what should I do or write t

相关标签:
7条回答
  • 2020-12-20 16:46

    You could also use a extension method for this:

    public static void ForceFocus(this AutoCompleteBox box)
    {
        if (box.Template.FindName("Text", box) is TextBox textbox)
        {
            textbox.Focus();
        }
    }
    
    0 讨论(0)
提交回复
热议问题