WPF等于ActiveControl吗? [英] WPF equivalent to ActiveControl?

查看:88
本文介绍了WPF等于ActiveControl吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Forms中,我可以简单地使用ActiveControl.name来获取活动控件的名称。但是,在WPF中这是行不通的。与Activecontrol.name等效的WPF命令是什么?无论哪种方式,我都会采用C#或VB。谢谢!

In Forms, I can simple use ActiveControl.name to get the name of the active control. However in WPF this doesn't work. What is the WPF command equivalent to Activecontrol.name? I'll take C# or VB, either way. Thank you!

推荐答案

虽然我不确定ActiveControl的确切匹配方式,但有两种可能:

There are a couple of possibilities though I'm not sure either is an exact match for ActiveControl:


  • Keyboard.FocusedElement:此静态成员告诉您当前应用程序中哪个元素具有键盘焦点
  • FocusManager.GetFocusedElement():这允许您在给定的焦点范围内获取焦点元素。请注意,不能在任意控件上使用此控件,只能在焦点范围内的控件上使用(即,将FocusManager.IsFocusScope设置为true)。
  • Keyboard.FocusedElement: this static member tells you which element has the keyboard focus in the current application
  • FocusManager.GetFocusedElement(): this allows you to get the focused element within a given focus scope. Note that this cannot be used on arbitrary controls, only on controls which are focus scopes (i.e. have FocusManager.IsFocusScope set to true).

这两个听起来像您想要的吗?

Do either of these sound like what you want?

这篇关于WPF等于ActiveControl吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆