Esempio n. 1
0
        protected virtual void OnCloseRequested(CloseEventHandlerArgs args)
        {
            RequestCloseEventHandler handler = CloseRequested;

            if (handler != null)
            {
                handler(this, args);
            }
        }
Esempio n. 2
0
        protected override void OnCloseRequested(CloseEventHandlerArgs args)
        {
            if (CollectionModified)
            {
                MessageBoxResult result = MessageBox.Show(
                    "Do you want to save the changes before closing?", "Save changes",
                    MessageBoxButton.YesNoCancel, MessageBoxImage.Question);

                switch (result)
                {
                case MessageBoxResult.Cancel:
                    return;

                case MessageBoxResult.Yes:
                    Save();
                    break;

                case MessageBoxResult.No:
                    Restore();
                    break;
                }
            }
            base.OnCloseRequested(args);
        }