Click here to Skip to main content
14,868,570 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hey all,

Does anyone know anything about the odd behaviour my WPF application is experiencing? I'm hoping it's something silly and simple, but it seems that if I interact with another window, e.g, if I minimise Internet Explorer, then my WPF window drops to the back of the desktop z-order.

Ideas and suggestions greatly appreciated,

Sergey Alexandrovich Kryukov 27-Apr-11 11:29am
Do you mean it? Do you really mean ***your*** application?
OK, do you mean: "when I minimize and then restore"?
Jibrohni 27-Apr-11 11:40am
It's a WCF/WPF application that transfers files from one pc to another. If I minimize an external window such as IE to see my applications UI then it doesn't minimize my applications window, but puts it to the back of all other open desktop windows? Sometimes it loses the start-bar icon too?

I'm not saying you don't have a problem. I'm saying the Question is pointless.

When you minimize application, the Z-order is not applicable to it as it goes to system tray.

Let's assume you're talking about Z-order after you restore the windows state back. Again, would be a pointless Question. When you restore it normally using keyboard/mouse, it is by definition on top of Z-order. If you restore it somehow programmatically, it can be anything. Nothing to discuss right now. Try to sort it out be yourself, as this is your code — I'm pretty much sure it has nothing to do with WFP specific stuff. If you face a problem and report it in a sensible way, I would gladly help.

Maybe it only puts it behind other IE/Explorer windows (same core process). Try it with Notepad and you may see that it only goes behind Notepad (which is correct behavior).

Losing the task-bar icon is weird, and is probably a different problem. Are you doing anything with the Window styles?
Jibrohni 28-Apr-11 4:37am
Nishant, I think you've better undertood my problem. But for more clarity I shall explain again.

Let's say I have 3 applications open, the topmost is Internet Explorer, second is my application, and thirdly is an Explorer window. So I wish to view my application by minimizing the IE window. For some reason this drops my application behind the Explorer window that was at the back to start with. I haven't even interacted with my application, but it's affected?

I agree that the icon issue is most likely something different. Now my application uses WindowStyle - SingleBorderWindow and implements a Glass Effect:

public static bool ExtendGlassFrame(Window window, Thickness margin)
if (IsGlassEnabled())

if (!DwmIsCompositionEnabled())
return false;
IntPtr hwnd = new WindowInteropHelper(window).Handle;
if (hwnd == IntPtr.Zero)
throw new InvalidOperationException("The Window must be shown before extending glass.");
// Set the background to transparent from both the WPF and Win32 perspectives
window.Background = Brushes.Transparent;
HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.Transparent;
MARGINS margins = new MARGINS(margin);
DwmExtendFrameIntoClientArea(hwnd, ref margins);
return true;
return false;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900