WPF焦点问题。控制不起作用 [英] WPF Focus Issues. Control Not Working

查看:54
本文介绍了WPF焦点问题。控制不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





在我的项目第一次加载页面时,所有控件都被禁用。

当我们点击新按钮时,控件已启用,将焦点设置在TextBox上。

但是光标聚焦是好的,当键盘上键入它时不显示它。







单击带有鼠标的TextBox或按Escape按钮后工作正常。







如何在没有鼠标单击或退出按钮的情况下解决它,

Hi,

In My Project First Time Page Loaded, All Controls Are Disable.
When We Clicking The New Button , Controls Are Enabled, Set Focus on TextBox.
But Cursor Focusing Is Ok, When Typing on The KeyBoard it Not Display on It.



After Clicking The TextBox With Mouse Or Pressing Escape Button is Works Correctly.



How To Solve it Without Mouse Click or Escape Button,

推荐答案

private void Button_Click(object sender, RoutedEventArgs e)
      {
          txt1.IsEnabled = true;
          txt2.IsEnabled = true;
          txt3.IsEnabled = true;
          txt1.Focus();
      }

      private void Window_Loaded(object sender, RoutedEventArgs e)
      {
          txt1.IsEnabled = false;
          txt2.IsEnabled = false;
          txt3.IsEnabled = false;
      }





这里txt1将得到专注,键盘工作正常而不点击txt1



here txt1 will be get focused and keyboard work fine without clicking txt1


这篇关于WPF焦点问题。控制不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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