Reputation: 2937
I am sure this is a duplicate, but I can't find the answer to this.
I have a WPF window called Popup (so I have Popup.Xaml, Popup.Xaml.cs). Is there a way to determine if there is an active (visible) window instance of this class? I need to check if the popup is currently visible and skip doing some actions in a different class (a class that has no UI control associated with it) if the Popup window is currently visible.
thanks,
Upvotes: 0
Views: 105
Reputation: 3506
When you create your Popup just create global variable public static bool isPopupVisible = true
(for ex in App class). Then you must handled event closing Popup and changed isPopupVisible = false
. And that's all. Only check this variable whenever you need.
Upvotes: 1
Reputation: 44028
if (Application.Current.Windows.OfType<YourWindowType>().Any(x => x.IsActive))
{
//... etc
}
Upvotes: 2