如何在WPF中获得重点控制? [英] How to get the focused control in WPF?
本文介绍了如何在WPF中获得重点控制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有什么办法可以在WPF中做到这一点?
解决方案
我做了什么
保护覆盖无效OnPreviewLostKeyboardFocus(KeyboardFocusChangedEventArgs e)
{
lostFocusControl = e.OldFocus;
$ b private void PauseButton_PreviewKeyDown(object sender,KeyEventArgs e)
{
//调用OnPreviewLostKeyboardFocus处理函数
}
How can I get a current focused control in WPF?
I found some solution for WinForms, but invoking WIN32 API function, didn't work in WPF?
Is there any way for doing it in WPF?
解决方案
Here's what I did
protected override void OnPreviewLostKeyboardFocus(KeyboardFocusChangedEventArgs e)
{
lostFocusControl = e.OldFocus;
}
private void PauseButton_PreviewKeyDown(object sender, KeyEventArgs e)
{
// invoke OnPreviewLostKeyboardFocus handler
}
这篇关于如何在WPF中获得重点控制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文