Fix OpenSettings command: ensure Main Window hides before showing Settings

- Call Hide() before scheduling SettingsWindow.Show() to ensure proper visibility state transition
- Use Dispatcher.UIThread.Post for showing the new window to avoid focus conflicts
This commit is contained in:
Hongtao Zhang 2026-01-19 00:13:42 -08:00
parent 19913fa1e6
commit 2b328e552a

View file

@ -214,16 +214,6 @@ public partial class MainViewModel : ObservableObject
public void Show()
{
MainWindowVisibility = true;
ShowRequested?.Invoke();
Log.Info(ClassName, "Show requested");
}
/// <summary>
/// Hide the main window.
/// </summary>
public void Hide()
{
MainWindowVisibility = false;
QueryText = "";
ActiveView = ActiveView.Results;
ContextMenu.Clear();
@ -382,8 +372,11 @@ public partial class MainViewModel : ObservableObject
public void OpenSettings()
{
Hide();
var settingsWindow = new SettingsWindow();
settingsWindow.Show();
global::Avalonia.Threading.Dispatcher.UIThread.Post(() =>
{
var settingsWindow = new SettingsWindow();
settingsWindow.Show();
});
}
[RelayCommand]