I have a function in a WPF MainWindow1.Xaml when application shuts down. But in unknown cases user can close application in another way then using the "file > close" button. I just need to know in the "Closing" methode if the current MainWindow1.xaml is already disposed or not. But I could not find any property.
Can you help me?
You can try
var source = PresentationSource.FromVisual(yourWindow)
If source
is null or source.IsDisposed == true
, that would indicate your Window has been closed.
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