开发者

WPF equivalent to ActiveControl?

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开发者_如何学Python.name? I'll take C# or VB, either way. Thank you!


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

  • 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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜