Quantcast
Viewing all articles
Browse latest Browse all 18858

Application.Shutdown() confirmation window

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?


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>