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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
No, but an attached behavior could be made to work for this.
回答2:
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);
}
}