kartal kartal - 1 year ago 194
C# Question

autocompletebox focus in wpf

when I try to focus on my "autocompletetextbox" I failed I write


but the cursor still focus in another what should I do or write to enable to write in it or focus?

Jay Jay
Answer Source

I experienced the same thing -- it does not work properly in its current form (I expect you're talking about the AutoCompleteBox that comes with the February 2010 release of WPFToolkit).

I created a subclass:

public class AutoCompleteFocusableBox : AutoCompleteBox
    public override void OnApplyTemplate()
        var textbox = Template.FindName("Text", this) as TextBox;
        if(textbox != null) textbox.Focus();

This sets focus to the actual TextBox (called "Text") that is part of the default ControlTemplate.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download