本文介绍了如何通过在wpf中按退格键来关注texbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以帮助我....如何在按下退格键的同时关注文本框和其他控件....
Can anybody help me....how can i focus textbox and other controls while pressing backspace key....
推荐答案
PreviewKeyUp=Window_PreviewKeyUp
private void Window_PreviewKeyUp(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.Key==System.Windows.Input.Key.Back)
{
e.Handled = true;
RequestFocusChange(FocusNavigationDirection.Previous);
}
}
private static bool RequestFocusChange(FocusNavigationDirection direction)
{
var focused = Keyboard.FocusedElement as UIElement;
if (focused != null) return focused.MoveFocus(new TraversalRequest(direction));
return false;
}
这篇关于如何通过在wpf中按退格键来关注texbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!