diff --git a/StabilityMatrix.Avalonia/ViewModels/Dialogs/EnvVarsViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Dialogs/EnvVarsViewModel.cs index 0500cd1c..52b255f5 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Dialogs/EnvVarsViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Dialogs/EnvVarsViewModel.cs @@ -1,5 +1,6 @@ -using System.Collections.Generic; +using System; using System.Collections.ObjectModel; +using System.Diagnostics; using Avalonia.Collections; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; @@ -26,10 +27,15 @@ public partial class EnvVarsViewModel : ContentDialogViewModelBase } [RelayCommand] - private void RemoveSelectedRow() + private void RemoveSelectedRow(int selectedIndex) { - if (EnvVarsView.CurrentItem is not EnvVarKeyPair envVar) return; - - EnvVars.Remove(envVar); + try + { + EnvVars.RemoveAt(selectedIndex); + } + catch (ArgumentOutOfRangeException) + { + Debug.WriteLine($"RemoveSelectedRow: Index {selectedIndex} out of range"); + } } } diff --git a/StabilityMatrix.Avalonia/Views/Dialogs/EnvVarsDialog.axaml b/StabilityMatrix.Avalonia/Views/Dialogs/EnvVarsDialog.axaml index e0e66f34..0f421d20 100644 --- a/StabilityMatrix.Avalonia/Views/Dialogs/EnvVarsDialog.axaml +++ b/StabilityMatrix.Avalonia/Views/Dialogs/EnvVarsDialog.axaml @@ -12,10 +12,19 @@ mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="StabilityMatrix.Avalonia.Views.Dialogs.EnvVarsDialog"> - - + + + + + + + @@ -34,12 +43,26 @@ - + - - + + + + + + + + + - + @@ -50,15 +73,19 @@ VerticalAlignment="Stretch" VerticalContentAlignment="Stretch"> +