/// <summary> /// Event raised when an AvalonDock DocumentContent is being closed. /// </summary> private void documentContent_Closing(object sender, CancelEventArgs e) { var documentContent = (DocumentContent)sender; var document = documentContent.DataContext; if (!disableClosingEvent) { if (this.DocumentClosing != null) { // // Notify the application that the document is being closed. // var eventArgs = new DocumentClosingEventArgs(document); this.DocumentClosing(this, eventArgs); if (eventArgs.Cancel) { // // Closing of the document is to be cancelled. // e.Cancel = true; return; } } } documentContent.Closing -= new EventHandler <CancelEventArgs>(documentContent_Closing); }
/// <summary> /// Event raised when a document is being closed by clicking the 'X' button in AvalonDock. /// </summary> private void avalonDockHost_DocumentClosing(object sender, DocumentClosingEventArgs e) { var document = (TextFileDocumentViewModel)e.Document; if (!this.ViewModel.QueryCanCloseFile(document)) { e.Cancel = true; } }