WPF prevent弹出窗口移除文本框的焦点窗口 [英] Wpf prevent Popup window from removing the focus of an Textbox
问题描述
在我的WPF应用中我用一个小窗口显示一些通知,但是当notificationwindow显示出来,在主窗口的焦点丢失。 例如,当我正在写在一个文本框和我收到的通知(通知窗口中显示出来),文本框失去焦点,我必须在文本框中再次点击继续我的工作。
In my WPF-Application I use a small window to display some notifications, but when the notificationwindow shows up, the focus in the mainwindow gets lost. For example when I'm writing in a TextBox and I'm receiving a notification (the notification window shows up), the textbox loses the focus and I have to click in the textbox again to continue my Work.
那么,如何能保持主窗口的焦点,当notificationwindow显示出来?我已经尝试过在notificationwindow设置可调焦=假
So how can I keep the focus of the mainwindow, when the notificationwindow shows up? I already tried to set Focusable="false" in the notificationwindow
推荐答案
有一个的 ShowActivated 财产Window对象,这样可以保持主窗口激活您展示一个子窗口后。
There is a ShowActivated property on Window object so you can keep the main window activated after you show a child window.
从MSDN:
当打开其ShowActivated属性窗口中设置为false,窗口不被激活,其激活事件不会上升,直到用户通过选择手动激活窗口。
When a window with its ShowActivated property set to false is opened, the window is not activated and its Activated event is not raised until a user manually activates the window by selecting it.
这篇关于WPF prevent弹出窗口移除文本框的焦点窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!