autocompletebox焦点在WPF [英] autocompletebox focus in wpf

查看:99
本文介绍了autocompletebox焦点在WPF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我试图把重点放在我的autocompletetextbox我失败了我写的 autocompletetextbox.focus()
但光标仍集中在另一个我应该怎么做或写入启用它来写还是集中?

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?

推荐答案

我经历了同样的事情 - 它不以目前的形式正常工作(我希望你在谈论自带的2010年2月发布的AutoCompleteBox WPFToolkit的)。

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).

我创建了一个子类:

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.

这篇关于autocompletebox焦点在WPF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆