Créer une App Moderne — Avalonia UI & .NET
Supprimer et basculer une tâche
public ObservableCollection<TodoItemViewModel> Taches { get; } = new();
[RelayCommand]
private void SupprimerTache(TodoItemViewModel item) => Taches.Remove(item);
<CheckBox IsChecked="{Binding IsDone}" Content="{Binding Title}" />
<Button Command="{Binding $parent[ItemsControl].DataContext.SupprimerTacheCommand}"
CommandParameter="{Binding}" Content="✕" />
CommandParameter transmet l'item concerné à la commande.
- Le ViewModel reste testable sans interface graphique.