WPF has the Popup class with which you can open a (small) window inside another window. This is used for example for Tooltips or ComboBoxes.
I need to find all of these popups which are currently opened inside a WPF window, so I can close them.
If someone still need:
public static IEnumerable<Popup> GetOpenPopups()
{
return PresentationSource.CurrentSources.OfType<HwndSource>()
.Select(h => h.RootVisual)
.OfType<FrameworkElement>()
.Select(f => f.Parent)
.OfType<Popup>()
.Where(p => p.IsOpen);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With