Is it possible to get the Hwnd of a WPF Popup control?

Maxim V. Pavlov picture Maxim V. Pavlov · Oct 19, 2011 · Viewed 7.9k times · Source

I need to apply an Aero background blur to only part of a custom-shaped WPF window. The problem is that to apply the blur with DWM, I need to provide a window handle to the DwmEnableBlurBehindWindow function.

I have been told that the WPF popup control is actually a separate window. That is good. Can I get a popup's handle to apply blur to it? If so, how?

Answer

dowhilefor picture dowhilefor · Oct 19, 2011

Try this

HwndSource source = (HwndSource)HwndSource.FromVisual(myPopup)

or this but this one only works for actual Windows, but might help for future references.

IntPtr handle = new WindowInteropHelper(myWindow).Handle;