Skip to content

Commit 821349a

Browse files
committed
feat: MessageBox add keyDown Esc close this
1 parent fb84655 commit 821349a

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/WPFDevelopers.Shared/Controls/MessageBox/WDMessageBox.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System;
77
using System.Windows;
88
using System.Windows.Controls;
9+
using System.Windows.Input;
910
using System.Windows.Media;
1011
using System.Windows.Shapes;
1112

@@ -223,6 +224,16 @@ private void CloseButton_Click(object sender, RoutedEventArgs e)
223224
Close();
224225
}
225226

227+
protected override void OnKeyDown(KeyEventArgs e)
228+
{
229+
base.OnKeyDown(e);
230+
if (e.Key == Key.Escape)
231+
{
232+
Close();
233+
e.Handled = true;
234+
}
235+
}
236+
226237
private void DisplayButtons(MessageBoxButton button)
227238
{
228239
switch (button)

0 commit comments

Comments
 (0)