refactor(ui): harden double-click edit handlers
Remove redundant SelectedList/SelectedTask assignments (single-tap already updated selection via binding) and CanExecute guards (always true for unconditional [RelayCommand]). Set e.Handled = true to stop DoubleTapped from bubbling to the ListBox. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -20,12 +20,11 @@ public partial class MainWindow : Window
|
|||||||
|
|
||||||
private void OnListItemDoubleTapped(object? sender, TappedEventArgs e)
|
private void OnListItemDoubleTapped(object? sender, TappedEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is Control c && c.DataContext is ListItemViewModel item
|
if (sender is Control c && c.DataContext is ListItemViewModel
|
||||||
&& DataContext is MainWindowViewModel vm)
|
&& DataContext is MainWindowViewModel vm)
|
||||||
{
|
{
|
||||||
vm.SelectedList = item;
|
vm.EditListCommand.Execute(null);
|
||||||
if (vm.EditListCommand.CanExecute(null))
|
e.Handled = true;
|
||||||
vm.EditListCommand.Execute(null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,12 +13,11 @@ public partial class TaskListView : UserControl
|
|||||||
|
|
||||||
private void OnTaskItemDoubleTapped(object? sender, TappedEventArgs e)
|
private void OnTaskItemDoubleTapped(object? sender, TappedEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is Control c && c.DataContext is TaskItemViewModel item
|
if (sender is Control c && c.DataContext is TaskItemViewModel
|
||||||
&& DataContext is TaskListViewModel vm)
|
&& DataContext is TaskListViewModel vm)
|
||||||
{
|
{
|
||||||
vm.SelectedTask = item;
|
vm.EditTaskCommand.Execute(null);
|
||||||
if (vm.EditTaskCommand.CanExecute(null))
|
e.Handled = true;
|
||||||
vm.EditTaskCommand.Execute(null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user