Find open windows in XAML

I need functionality to get all existing (open) instances of some window WPF. I create these programs programmatically in several places in the code.

Is there a XAML / WPF solution for this? Something like GetInstancesByType(type)?

+3
source share
1 answer

You can use the Application.Windows property :

foreach( var window in Application.Current.Windows.OfType<MyType>() )
{
    // do stuff
}

Like HB, what you need to include System.Linqin order to get the extension method OfType<T>, but this is optional.

+4
source

All Articles