fix: fix not clear texts while hide

master
ZGGSONG 2 years ago
parent bc40050c9f
commit d94b20f39b

@ -20,9 +20,6 @@
Height="450"
Width="400"
Icon="/Images/translate.ico">
<Window.DataContext>
<vm:MainVM/>
</Window.DataContext>
<Border BorderThickness="0"
Background="#fff"
CornerRadius="10">

@ -1,4 +1,5 @@
using STranslate.Utils;
using STranslate.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
@ -58,6 +59,7 @@ namespace STranslate
public MainWindow()
{
InitializeComponent();
this.DataContext = MainVM.Instance;
}
/// <summary>
@ -81,8 +83,8 @@ namespace STranslate
if (e.Key == Key.Escape)
{
this.Hide();
this.TextBoxInput.Text = string.Empty;
this.TextBoxOutput.Text = string.Empty;
MainVM.Instance.InputTxt = string.Empty;
MainVM.Instance.OutputTxt = string.Empty;
}
//退出 Ctrl+Q
if (e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Control) && e.Key == Key.Q)
@ -138,9 +140,9 @@ namespace STranslate
/// <param name="e"></param>
private void Window_Deactivated(object sender, EventArgs e)
{
//this.Hide();
//this.TextBoxInput.Text = string.Empty;
//this.TextBoxOutput.Text = string.Empty;
this.Hide();
MainVM.Instance.InputTxt = string.Empty;
MainVM.Instance.OutputTxt = string.Empty;
}
}
}

@ -94,5 +94,8 @@ namespace STranslate.ViewModel
private string _OutputComboSelected;
public string OutputComboSelected { get => _OutputComboSelected; set => UpdateProperty(ref _OutputComboSelected, value); }
private static readonly MainVM _Instance = new MainVM();
public static MainVM Instance { get => _Instance; }
}
}