开发者

MaskedTextBox Focus Method Doesn't Work

I am using the Extended WPF Toolkit in one of my applications, and I am using the MaskedTextBox control. When I call the Focus method on the control, it doesn't work. The Focus method works fine on TextBox controls, but it seems that th开发者_JS百科e MaskedTextBox doesn't inherit from TextBox. Does anyone know how to programmatically give focus to this control?


See if this works. I had to do this to the DatePicker in silverlight. Derive a control from MaskedTextBox and provide the following overrides.

public override void OnApplyTemplate()
{
    base.OnApplyTemplate();

    _textBox = (TextBox)base.GetTemplateChild("TextBox");
}

public new void Focus()
{
    if (_textBox == null)
        base.Focus();
    else
        _textBox.Focus();
}

private TextBox _textBox;


You should submit the issues to the project site so it can be fixed in the toolkit and everyone can benefit.

http://wpftoolkit.codeplex.com/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜