Leere Liste nur in GUI

This commit is contained in:
2025-06-02 16:36:48 +02:00
parent 5b2b05ed55
commit 99640602f5
2 changed files with 20 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
using FahrzeugDatenBank;
using System.Collections.ObjectModel;
using System.Timers;
using System.Windows;
using System.Windows.Input;
namespace FahzeugWPF;
@@ -21,9 +22,11 @@ class MainWindowViewModel : ViewModelBase
this._model = modell;
this.InitialisiereDasViewModell();
this.LoeschenKommando = new RelayCommand(LoescheFahrzeug);
this.LeerenKommando = new RelayCommand(LeereListe);
}
public ICommand LoeschenKommando { get; private set; }
public ICommand LeerenKommando { get; private set; }
public string MainWindowTitle
{
@@ -56,4 +59,15 @@ class MainWindowViewModel : ViewModelBase
_model.LoescheFahrzeug((Fahrzeug)fahrzeug);
this.Fahrzeuge.Remove((Fahrzeug)fahrzeug);
}
private async void LeereListe(object? o)
{
await Task.Run(() =>
{
Application.Current.Dispatcher.Invoke(() =>
{
this.Fahrzeuge.Clear();
});
});
}
}