Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 to enable to write in it or focus?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
346 views
Welcome To Ask or Share your Answers For Others

1 Answer

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()
    {
        base.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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...