|
Dieser Artikel wurde maschinell übersetzt. Bewegen Sie den Mauszeiger über die Sätze im Artikel, um den Originaltext anzuzeigen. Weitere Informationen
|
Übersetzung
Original
|
Window.Closing-Ereignis
Namespace: System.Windows
Assembly: PresentationFramework (in PresentationFramework.dll)
XMLNS für XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
| Ausnahme | Bedingung |
|---|---|
| InvalidOperationException |
<Window x:Class="CSharp.DataWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Closing="DataWindow_Closing" > ... </Window>
Imports System ' EventArgs Imports System.ComponentModel ' CancelEventArgs Imports System.Windows ' window Namespace VisualBasic Partial Public Class DataWindow Inherits Window ' Is data dirty Private isDataDirty As Boolean = False ... Private Sub DataWindow_Closing(ByVal sender As Object, ByVal e As CancelEventArgs) MessageBox.Show("Closing called") ' If data is dirty, notify user and ask for a response If Me.isDataDirty Then Dim msg As String = "Data is dirty. Close without saving?" Dim result As MessageBoxResult = MessageBox.Show(msg, "Data App", MessageBoxButton.YesNo, MessageBoxImage.Warning) If result = MessageBoxResult.No Then ' If user doesn't want to close, cancel closure e.Cancel = True End If End If End Sub End Class End Namespace
using System; // EventArgs using System.ComponentModel; // CancelEventArgs using System.Windows; // window namespace CSharp { public partial class DataWindow : Window { // Is data dirty bool isDataDirty = false; ... void DataWindow_Closing(object sender, CancelEventArgs e) { MessageBox.Show("Closing called"); // If data is dirty, notify user and ask for a response if (this.isDataDirty) { string msg = "Data is dirty. Close without saving?"; MessageBoxResult result = MessageBox.Show( msg, "Data App", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.No) { // If user doesn't want to close, cancel closure e.Cancel = true; } } } } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core-Rolle wird nicht unterstützt), Windows Server 2008 R2 (Server Core-Rolle wird mit SP1 oder höher unterstützt; Itanium wird nicht unterstützt)
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen für .NET Framework.