Instable focus of WPF apps

瘦欲@ 提交于 2019-12-01 11:07:34

For losing focus for the entire app make sure you set the Owner property on all windows before you show them.

For losing focus inside the app, usually this happens when some control you didn't think off is getting but not showing anything (for example some random StackPanel or Grid used for layout), you have to hunt those down and add Focusable="false"

+1 As I have also faced similar issues in my application. I am working on a VS like application(user can add(from toolbox) and configure controls in a Canvas) and focus is lost mysteriously after various commnads are executed like Delete etc. I have to use Canvas.Focus() explicitly to reset the focus and that too doesn't work sometimes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!