开发者

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...

  1. Make your Window handle Keyboard.PreviewLostKeyboardFocus.

    <Window Keyboard.PreviewLostKeyboardFocus="KeyboardFocusChangedEventHandler" ... />
    
  2. 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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜