Skip to content

Commit

Permalink
新增Esc键退出预览功能
Browse files Browse the repository at this point in the history
  • Loading branch information
theyangfan committed Apr 9, 2023
1 parent 5fd0e35 commit e26242b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion PictureViewer.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WordPictureViewer"
mc:Ignorable="d"
Title="图片预览" d:DesignHeight="450" d:DesignWidth="800" Background="#CC000000">
Title="图片预览" d:DesignHeight="450" d:DesignWidth="800" Background="#CC000000" KeyDown="Window_KeyDown">
<Window.Resources>
<Style x:Key="ImageBtnStyle1" TargetType="{x:Type Button}">
<Setter Property="Background" Value="Transparent"/>
Expand Down
11 changes: 11 additions & 0 deletions PictureViewer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,17 @@ private void UICloseBtn_Click(object sender, RoutedEventArgs e)
{
Close();
}

private void Window_KeyDown(object sender, KeyEventArgs e)
{
if(e.Key == Key.Escape)
{
Close();
}
}
#endregion



}
}

0 comments on commit e26242b

Please sign in to comment.