I have a wpf project which has couple of windows, whne i navigate from one window to other i just hide one window and create instance of other if not created already
in all windows there is window closing event handler
private void Window_Closing_1(object sender, CancelEventArgs e) { { string message = "You are trying to close window " + this.Name + " .Are you sure?"; string caption = "Exit"; MessageBoxButton buttons = MessageBoxButton.YesNo; MessageBoxImage icon = MessageBoxImage.Question; if (MessageBox.Show(message, caption, buttons, icon) == MessageBoxResult.Yes) { App.Current.Shutdown(); } else { MessageBox.Show("Closing aborted"); } }but problem is this event is there in every window so when i close it lots of other prompt from other window also show up. Is there a way to avoid other pronpts if i close in only one window?