Possible Duplicate:
How can I assign the 'Close on Escape-key press' behavior to all WPF windows within a project?
Here is a button-less solution that is clean and more MVVM-ish. Add the following XAML into your dialog/window:
and handle the event in the code-behind:
private void CloseCommandBinding_Executed(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
{
if (MessageBox.Show("Close?", "Close", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
this.Close();
}