WPF label counterpart for HTML “for” attribute

后端 未结 2 1345
孤独总比滥情好
孤独总比滥情好 2021-01-13 18:51

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 w

相关标签:
2条回答
  • 2021-01-13 18:56

    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);
        }
    }
    
    0 讨论(0)
  • 2021-01-13 19:09

    No, but an attached behavior could be made to work for this.

    0 讨论(0)
提交回复
热议问题