C
C#10mo ago
Pandetthe

Find popup window in Wpf

Hi, I want to get all opened popups in a specific window in Wpf, but I couldn't find a solution to solve it.
3 Replies
Pandetthe
PandettheOP10mo ago
I found that in Uwp exists VisualTreeHelper.GetOpenPopups(), but is there any option to use it in Wpf?
bighugemassive3
bighugemassive310mo ago
You could use reflection to access the Window._showingAsDialog field, then iterate it using Application.Current.Windows.Cast<Window>().Where(x => x.Parent == targetParenttWindow && IsOpenedAsDialog(x))
Pandetthe
PandettheOP10mo ago
It's not working for popups used for example in combobox I found solution
PresentationSource.CurrentSources.OfType<HwndSource>()
.Select(h => h.RootVisual)
.OfType<FrameworkElement>()
.Select(f => f.Parent)
.OfType<Popup>()
.Where(popup => popup.IsOpen);
PresentationSource.CurrentSources.OfType<HwndSource>()
.Select(h => h.RootVisual)
.OfType<FrameworkElement>()
.Select(f => f.Parent)
.OfType<Popup>()
.Where(popup => popup.IsOpen);
Want results from more Discord servers?
Add your server