开发者

WPF application gets focus event

开发者 https://www.devze.com 2023-02-06 23:39 出处:网络
My WPFapplication has windows that are running on separate dispatchers. I need to be able to tell those windows to开发者_运维知识库 activate when the main window has focus. What event should I listen

My WPF application has windows that are running on separate dispatchers. I need to be able to tell those windows to开发者_运维知识库 activate when the main window has focus. What event should I listen too to know when the application has focus?


Application.Activated event is a good place. When you get this event, your application has been activated by the user (either mouse click or keyboard focus switched to it).


It's not clear from the question if you want to know about the application getting focus (in which case, Franci is right) or when the main window gets focus. For the main window (or any particular window), there is a GotFocus event inherited from UIElement http://msdn.microsoft.com/en-us/library/system.windows.uielement.gotfocus.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消