WPF TreeView restores its focus after double click

前端 未结 2 1953
甜味超标
甜味超标 2021-01-12 13:26

I have a WPF TreeView with XAML shown below:


            
                

        
相关标签:
2条回答
  • 2021-01-12 14:08

    in constructor of new form set

    this.Focus();
    

    Also, does your new form should be Modal window? if yes use Editor.ShowDialog() instead of Editor.Show(); It will automatically solve issue with focus

    0 讨论(0)
  • 2021-01-12 14:13

    You probably need to let WPF finish the job of handling the current mouse click event(s) before you open the new Window. Let the new window be the next UI job by adding it to the current Dispatcher's queue like this:

    (...)
    
    //Editor.Show();
    Action showAction = () => Editor.Show();
    this.Dispatcher.BeginInvoke(showAction);
    
    0 讨论(0)
提交回复
热议问题