Recently I have this bug inherited from my good intern that WPF <Popup/>
will always be TOP_MOST in terms of z-index. The bug scenario is that
when you have another application (eg. notepad.exe) going on top of my
WPF application (with Popup launched), Popup will be top most even
though notepad appears on top of my app. So to fix this, I'm using some
old Win32 tricks :-) [DllImport("user32", EntryPoint = "SetWindowPos")] { ... protected override void OnOpened(EventArgs e) { IntPtr hwnd = ((HwndSource)PresentationSource.FromVisual(this.Child)).Handle; SetWindowPos(hwnd, -2, posX, posY, (int)this.Width, (int)this.Height, 0); } } |
|