简体   繁体   中英

WPF label counterpart for HTML “for” attribute

Is there some attribute in WPF that I can add to element, so when I click it the target control get focus? The closest thing I have found is 'Target', but it works only with access keys and clicking it has no effect.

override the Label control

public class LabelEx : Label
{
    public LabelEx() : base() {}

    protected override void OnMouseDown(System.Windows.Input.MouseButtonEventArgs e)
    {
        if (Target != null) Target.Focus();
        base.OnMouseDown(e);
    }
}

不,但可以使附加行为为此工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM