Search code examples
.netwpfpopuphandle

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


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?


Solution

  • 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;