Open WPF Popup Control without focus
I want to know if there is a way to open a WPF Popup without move focus to it.
When I set the property IsOpen = true of the Pupup the Applciation window lost focus (the Deactivated event is fired) and the focis is moved to the Popup and I want to maintain the window with the focus.
I already tried the method FocusManager.GetFocusedElement
to get the previous element with focus and then set the focus to it again but 开发者_C百科it doesn't work for me.
Any ideas?
Thanks in advance.
Can you try one thing...
Make your Window handle Keyboard.PreviewLostKeyboardFocus.
<Window Keyboard.PreviewLostKeyboardFocus="KeyboardFocusChangedEventHandler" ... />
In your handler handle the event for when popup is open.
private void KeyboardFocusChangedEventHandler(object sender, KeyboardFocusChangedEventArgs e) { e.Handled = this.popup.IsOpen; }
Let me know if this works....
Try setting the Focusable
property to false.
精彩评论