I need to do a task in WPF, which was no problem in WinForms - when user attempts to close main window and there are unsaved data, show confirmation dialog and potentially cancel the closing.
I tried to use Window.Closing event for this. Event comes, cancellation works, but problem is, that I can not show a modal dialog. Attempt to do it results in InvalidOperationException with message like "Can not set Visibility to Visible, or call Show, ShowDialog, or Close while a window is closing." This is even described in documentation. So, how can I display simple modal dialog like "There are unsaved data, do you want to save them? Yes, No, Cancel"?