Is there a way to get a list of all windows in Avalonia?
The equivalent of this in WPF
Application.Current.Windows
My requirement is to activate or close a certain window based on its DataContext.
If I can't access such a list; is there a way to track the creation and destruction of windows to create an internal list?
You need IClassicDesktopStyleApplicationLifetime::Windows property. Lifetime is available from Application's ApplicationLifetime property.
e. g.
((IClassicDesktopStyleApplicationLifetime)Application.Current.ApplicationLifetime).Windows
Note that it's not available for Mobile, WebAssembly and Linux framebuffer platforms.
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