focus visual not showing when navigating focus programically

前端 未结 1 702
不思量自难忘°
不思量自难忘° 2021-01-14 20:03

Whenever I try to move focus programmatically the focus visual (the dotted rectangle) does not display.

What can be done to force this visual to display?

<         


        
相关标签:
1条回答
  • 2021-01-14 20:29

    If you look (in reflector/ilspy) at the KeyboardNavigation's ShowFocusVisual you'll find that the framework will only show it if the last input was from the keyboard (or if an internal static property based on the KeyboardCues system parameter info is true). So I don't think there is a good way to do this short of using reflection to temporarily set that property or asynchronously focusing the element and forcing a keyboard action (maybe using the winforms SendKeys or keybd_event api) but I wouldn't recommend either.

    0 讨论(0)
提交回复
热议问题