Skip to content

Commit 076db04

Browse files
authored
Added the ability to use the escape key to exit the properties window (#1504)
1 parent 0027639 commit 076db04

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Files/Interacts/Interaction.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,12 @@ private async Task OpenPropertiesWindow(object item)
535535
{
536536
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
537537
{
538+
538539
AppWindow appWindow = await AppWindow.TryCreateAsync();
539540
Frame frame = new Frame();
540541
appWindow.TitleBar.ExtendsContentIntoTitleBar = true;
541542
frame.Navigate(typeof(Properties), item, new SuppressNavigationTransitionInfo());
543+
542544
WindowManagementPreview.SetPreferredMinSize(appWindow, new Size(400, 500));
543545

544546
appWindow.RequestSize(new Size(400, 475));

Files/Views/Pages/Properties.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
Loaded="Properties_Loaded"
1616
RequestedTheme="{x:Bind local1:ThemeHelper.RootTheme}"
1717
Unloaded="Properties_Unloaded"
18-
mc:Ignorable="d">
18+
mc:Ignorable="d" KeyDown="Page_KeyDown">
1919
<Page.Background>
2020
<AcrylicBrush
2121
Windows10version1903:TintLuminosityOpacity="0.9"

Files/Views/Pages/Properties.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
using System.Threading;
1010
using Windows.Foundation.Metadata;
1111
using Windows.Storage;
12+
using Windows.System;
1213
using Windows.UI;
1314
using Windows.UI.WindowManagement;
1415
using Windows.UI.Xaml;
1516
using Windows.UI.Xaml.Controls;
17+
using Windows.UI.Xaml.Input;
1618
using Windows.UI.Xaml.Navigation;
1719

1820
namespace Files
@@ -131,5 +133,13 @@ private async void Button_Click(object sender, RoutedEventArgs e)
131133
propertiesDialog.Hide();
132134
}
133135
}
136+
137+
async void Page_KeyDown(object sender, KeyRoutedEventArgs e)
138+
{
139+
if (e.Key.Equals(VirtualKey.Escape) && ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
140+
{
141+
await propWindow.CloseAsync();
142+
}
143+
}
134144
}
135145
}

0 commit comments

Comments
 (0)