[UI] Fix Settings-window doesn't show back up when minimized in taskbar by user

Not sure why this works tho
Maybe `.Show()` failed when `window.WindowState == Minimized` (not `Normal`)
Not sure why need .Activate() too
Ref: https://stackoverflow.com/a/59719760/4230390
This commit is contained in:
pc223 2021-06-22 17:46:01 +07:00
parent 9fc97c6f6d
commit d3384bf677

View file

@ -11,7 +11,19 @@ namespace Flow.Launcher.Helper
var window = Application.Current.Windows.OfType<Window>().FirstOrDefault(x => x.GetType() == typeof(T))
?? (T)Activator.CreateInstance(typeof(T), args);
Application.Current.MainWindow.Hide();
// Fix UI bug
// If only use `window.Show()`, Settings-window doesn't show when minimized in taskbar
// Not sure why this works tho
// Probably because, when `.Show()` failed, `window.WindowState == Minimized` (not `Normal`)
// https://stackoverflow.com/a/59719760/4230390
// Not sure why need .Activate() too
window.WindowState = WindowState.Normal;
window.Show();
window.Activate();
window.Focus();
return (T)window;