开发者

WPF: Popup always floats on top. How do i correct that?

The popup that gets opened in my app always stays on top. It goes away when i minimize开发者_运维知识库 the app. But otherwise if the app opens a new window or if i switch to another program without minimizing the app, the popup stays on top. How do i hide the popup when the app loses focus?

Thanks


It sounds like you need to set the owner/parent of the popup to the correct window by setting the Owner property to the window that created it.


You can pass owner (parent window) to the constructor of the popup window and then specify

public class PopupWindow: Window
{
    public PopupWindow(Window owner)
    {
        this.Owner = owner;
    }
}

Then open your popup window

Now to open your popup window you will use something like this:

var popup = new PopupWindow(ownerWindow);
popup.Show();

or if caller is a parent (owner)

var popup = new PopupWindow(this);
popup.Show();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜