File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,12 +31,6 @@ public TaskListViewModel(
3131 Tasks . Add ( taskCreationViewModel . CreatedTask ) ;
3232 } ) ;
3333
34- Edit = new RelayCommand < Task > ( taskToEdit =>
35- {
36- var window = new TaskEditing ( taskToEdit ! ) ;
37- window . ShowDialog ( ) ;
38- } ) ;
39-
4034 Delete = new RelayCommand < Task > ( taskToRemove =>
4135 {
4236 Tasks . Remove ( taskToRemove ! ) ;
@@ -46,7 +40,6 @@ public TaskListViewModel(
4640
4741 public ICommand Add { get ; }
4842
49- public ICommand Edit { get ; }
5043 public ICommand Delete { get ; }
5144
5245 public void PopulateTasks ( )
Original file line number Diff line number Diff line change 66 xmlns : mc =" http://schemas.openxmlformats.org/markup-compatibility/2006"
77 mc : Ignorable =" d"
88 xmlns : domain =" clr-namespace:Desktop.Domain" >
9+ <UserControl .Resources>
10+ <Style TargetType =" ListBoxItem" >
11+ <EventSetter Event =" MouseDoubleClick" Handler =" Edit" />
12+ </Style >
13+ </UserControl .Resources>
914 <Grid >
1015 <StackPanel >
1116 <StackPanel Orientation =" Horizontal" >
1823 <DataTemplate DataType =" {x:Type domain:Task}" >
1924 <StackPanel Orientation =" Horizontal" >
2025 <TextBlock Text =" {Binding Name}" />
21- <Button Content =" Edit"
22- Command =" {Binding DataContext.Edit, ElementName=Root}"
23- CommandParameter =" {Binding}" />
2426 <Button Content =" Delete"
2527 Command =" {Binding DataContext.Delete, ElementName=Root}"
2628 CommandParameter =" {Binding}" />
Original file line number Diff line number Diff line change 11using System . Windows . Controls ;
2+ using System . Windows . Input ;
23using Desktop . Tasks ;
4+ using Task = Desktop . Domain . Task ;
35
46namespace Desktop . Project ;
57
@@ -16,4 +18,13 @@ public TasksList(TaskListViewModel viewModel)
1618 viewModel . TaskCreationViewCreator = creationViewModel =>
1719 new TaskCreation ( creationViewModel ) ;
1820 }
21+
22+ private void Edit ( object sender , MouseButtonEventArgs e )
23+ {
24+ if ( sender is not ListBoxItem { DataContext : Task task } )
25+ return ;
26+
27+ var window = new TaskEditing ( task ) ;
28+ window . ShowDialog ( ) ;
29+ }
1930}
Original file line number Diff line number Diff line change 11using System . Windows ;
2- using Desktop . Common ;
32using Task = Desktop . Domain . Task ;
43
54namespace Desktop . Tasks ;
You can’t perform that action at this time.
0 commit comments