初始版本
This commit is contained in:
@@ -7,10 +7,11 @@
|
||||
xmlns:models="clr-namespace:TodoList.Models"
|
||||
xmlns:converters="clr-namespace:TodoList.Converters"
|
||||
mc:Ignorable="d"
|
||||
Title="待办事项" Height="600" Width="450"
|
||||
Title="{Binding AppVersion, StringFormat='待办事项 v{0}'}" Height="600" Width="450"
|
||||
Background="#F5F5F7"
|
||||
Icon="/icon.ico"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
WindowStartupLocation="CenterScreen"
|
||||
PreviewKeyDown="Window_PreviewKeyDown">
|
||||
|
||||
<Window.Resources>
|
||||
<ObjectDataProvider x:Key="PriorityEnum" MethodName="GetValues"
|
||||
|
||||
@@ -19,6 +19,25 @@ namespace TodoList.Views
|
||||
// Verify if app shuts down? No, ShutdownMode is Explicit.
|
||||
}
|
||||
|
||||
private void Window_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
// If settings are open, close settings?
|
||||
// But user requirement is "Equals pressing X button", which usually means Close/Hide window.
|
||||
// However, if we want better UX:
|
||||
if (DataContext is MainViewModel vm && vm.IsSettingsOpen)
|
||||
{
|
||||
vm.IsSettingsOpen = false;
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Default behavior: Close (Hide) Window
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void ShortcutBox_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
|
||||
Reference in New Issue
Block a user