<bdo id='2AWQW'></bdo><ul id='2AWQW'></ul>
    1. <small id='2AWQW'></small><noframes id='2AWQW'>

      <tfoot id='2AWQW'></tfoot>

        <legend id='2AWQW'><style id='2AWQW'><dir id='2AWQW'><q id='2AWQW'></q></dir></style></legend>

        <i id='2AWQW'><tr id='2AWQW'><dt id='2AWQW'><q id='2AWQW'><span id='2AWQW'><b id='2AWQW'><form id='2AWQW'><ins id='2AWQW'></ins><ul id='2AWQW'></ul><sub id='2AWQW'></sub></form><legend id='2AWQW'></legend><bdo id='2AWQW'><pre id='2AWQW'><center id='2AWQW'></center></pre></bdo></b><th id='2AWQW'></th></span></q></dt></tr></i><div id='2AWQW'><tfoot id='2AWQW'></tfoot><dl id='2AWQW'><fieldset id='2AWQW'></fieldset></dl></div>

        WPF TabControl On SelectionChanged,将焦点设置到文本字

        时间:2023-06-04
      1. <i id='P8L9Y'><tr id='P8L9Y'><dt id='P8L9Y'><q id='P8L9Y'><span id='P8L9Y'><b id='P8L9Y'><form id='P8L9Y'><ins id='P8L9Y'></ins><ul id='P8L9Y'></ul><sub id='P8L9Y'></sub></form><legend id='P8L9Y'></legend><bdo id='P8L9Y'><pre id='P8L9Y'><center id='P8L9Y'></center></pre></bdo></b><th id='P8L9Y'></th></span></q></dt></tr></i><div id='P8L9Y'><tfoot id='P8L9Y'></tfoot><dl id='P8L9Y'><fieldset id='P8L9Y'></fieldset></dl></div>

          1. <legend id='P8L9Y'><style id='P8L9Y'><dir id='P8L9Y'><q id='P8L9Y'></q></dir></style></legend>
              <tbody id='P8L9Y'></tbody>
            <tfoot id='P8L9Y'></tfoot>
            • <bdo id='P8L9Y'></bdo><ul id='P8L9Y'></ul>
              • <small id='P8L9Y'></small><noframes id='P8L9Y'>

                1. 本文介绍了WPF TabControl On SelectionChanged,将焦点设置到文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有一个选项卡控件和一些选项卡项.我正在成功监听 SelectionChanged 事件,并检查我感兴趣的选项卡是否是当前选定的选项卡.

                  I have a tab control, and a few tab items. I am successfully listening to the SelectionChanged event, and checking if the tab I'm interested in is the currently selected one.

                  我正在使用这段代码(如下),并逐步通过调试器,我可以看到我的分支逻辑按设计工作;但是,我遇到的问题是某些东西覆盖了对 txt.Focus() 的调用,因为在显示正确的选项卡项后,焦点不在文本框上.

                  I'm using this code (below), and stepping through the debugger, I can see that my branching logic works as designed; however, the issue I'm having is that something is overriding this call to txt.Focus() because after the correct tab item is displayed, the focus is not on the text box.

                  private void tabMain_SelectionChanged(object sender, SelectionChangedEventArgs e)
                  {
                      // exact same behavior with and without this line
                      e.Handled = true;
                  
                      if (e.AddedItems.Contains(usrTab))
                      {
                          txtusr.Focus();
                      }
                      else if (e.AddedItems.Contains(svcTab))
                      {
                          txtsvc.Focus();
                      }
                  }
                  

                  如果我只是将 txtusr.Focus() 放在按钮事件处理程序中,它会完全按照我的预期聚焦.

                  If I just put txtusr.Focus() in a button event handler, it focuses exactly as I'd expect.

                  我怀疑这与调用 .Focus() 方法时未加载 tabitem 内容有关,但我不确定如何修复它.

                  I suspect that this has to do with the tabitem content not being loaded at the time the .Focus() method is called, but I'm not sure how to go about fixing it.

                  推荐答案

                  尝试将 .Focus() 调用放在 dispatcher.BeginInvoke 中.

                  Try putting the .Focus() calls inside a dispatcher.BeginInvoke.

                  Dispatcher.BeginInvoke(new Action(() => { txtsvc.Focus(); }));
                  

                  这篇关于WPF TabControl On SelectionChanged,将焦点设置到文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:WPF 错误样式仅在选项卡控件的可见选项卡上正确 下一篇:更改带有选项卡的接受按钮

                  相关文章

                  最新文章

                  <tfoot id='R5g32'></tfoot>

                    • <bdo id='R5g32'></bdo><ul id='R5g32'></ul>
                      <legend id='R5g32'><style id='R5g32'><dir id='R5g32'><q id='R5g32'></q></dir></style></legend>
                    1. <small id='R5g32'></small><noframes id='R5g32'>

                    2. <i id='R5g32'><tr id='R5g32'><dt id='R5g32'><q id='R5g32'><span id='R5g32'><b id='R5g32'><form id='R5g32'><ins id='R5g32'></ins><ul id='R5g32'></ul><sub id='R5g32'></sub></form><legend id='R5g32'></legend><bdo id='R5g32'><pre id='R5g32'><center id='R5g32'></center></pre></bdo></b><th id='R5g32'></th></span></q></dt></tr></i><div id='R5g32'><tfoot id='R5g32'></tfoot><dl id='R5g32'><fieldset id='R5g32'></fieldset></dl></div>