WPF label counterpart for HTML “for” attribute
-
22-08-2019 - |
Question
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.
Solution
No, but an attached behavior could be made to work for this.
OTHER TIPS
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);
}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow