fix(ui): context menu operates on right-clicked item and gates new-task on list selection

- Add PointerPressed handlers on list/task item templates that set SelectedList/SelectedTask on right-click before the ContextFlyout opens
- Add CanAddTask guard and NotifyCanExecuteChangedFor on CurrentListId so Add Task menu item is disabled when no list is selected

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mika Kuns
2026-04-13 15:11:34 +02:00
parent 3653dcad01
commit 5d5a583af0
5 changed files with 26 additions and 4 deletions

View File

@@ -24,7 +24,7 @@ public partial class TaskListViewModel : ViewModelBase
public ObservableCollection<TaskItemViewModel> Tasks { get; } = new();
[ObservableProperty] private TaskItemViewModel? _selectedTask;
[ObservableProperty] private string? _currentListId;
[ObservableProperty, NotifyCanExecuteChangedFor(nameof(AddTaskCommand))] private string? _currentListId;
public event Action<TaskItemViewModel?>? SelectedTaskChanged;
@@ -69,7 +69,9 @@ public partial class TaskListViewModel : ViewModelBase
}
}
[RelayCommand]
private bool CanAddTask() => CurrentListId is not null;
[RelayCommand(CanExecute = nameof(CanAddTask))]
private async Task AddTask()
{
if (CurrentListId is null) return;