diff --git a/StabilityMatrix.Avalonia/ViewModels/InferenceViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/InferenceViewModel.cs index 295f688f..ab697e75 100644 --- a/StabilityMatrix.Avalonia/ViewModels/InferenceViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/InferenceViewModel.cs @@ -30,6 +30,9 @@ public partial class InferenceViewModel : PageViewModelBase, IDisposable public bool IsConnected => Client is not null; public AvaloniaList Tabs { get; } = new(); + + [ObservableProperty] + private ViewModelBase? selectedTab; public InferenceViewModel(ServiceManager vmFactory, IApiFactory apiFactory, INotificationService notificationService) { @@ -52,6 +55,13 @@ public partial class InferenceViewModel : PageViewModelBase, IDisposable { Tabs.Add(CreateTextToImageViewModel()); } + + // Select first tab if none is selected + if (SelectedTab is null && Tabs.Count > 0) + { + SelectedTab = Tabs[0]; + } + base.OnLoaded(); } diff --git a/StabilityMatrix.Avalonia/Views/InferencePage.axaml b/StabilityMatrix.Avalonia/Views/InferencePage.axaml index 5855969f..d79aae4d 100644 --- a/StabilityMatrix.Avalonia/Views/InferencePage.axaml +++ b/StabilityMatrix.Avalonia/Views/InferencePage.axaml @@ -26,6 +26,7 @@ TabStripHeader="" AddTabButtonCommand="{Binding AddTabCommand}" TabItems="{Binding Tabs}" + SelectedItem="{Binding SelectedTab, Mode=TwoWay}" TabWidthMode="SizeToContent">