Browse Source

Keep selected tab

pull/165/head
Ionite 1 year ago
parent
commit
9b22b02490
No known key found for this signature in database
  1. 10
      StabilityMatrix.Avalonia/ViewModels/InferenceViewModel.cs
  2. 1
      StabilityMatrix.Avalonia/Views/InferencePage.axaml

10
StabilityMatrix.Avalonia/ViewModels/InferenceViewModel.cs

@ -30,6 +30,9 @@ public partial class InferenceViewModel : PageViewModelBase, IDisposable
public bool IsConnected => Client is not null;
public AvaloniaList<ViewModelBase> Tabs { get; } = new();
[ObservableProperty]
private ViewModelBase? selectedTab;
public InferenceViewModel(ServiceManager<ViewModelBase> 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();
}

1
StabilityMatrix.Avalonia/Views/InferencePage.axaml

@ -26,6 +26,7 @@
TabStripHeader=""
AddTabButtonCommand="{Binding AddTabCommand}"
TabItems="{Binding Tabs}"
SelectedItem="{Binding SelectedTab, Mode=TwoWay}"
TabWidthMode="SizeToContent">
<ui:TabView.TabItemTemplate>
<DataTemplate DataType="{x:Type vmInference:InferenceTextToImageViewModel}">

Loading…
Cancel
Save