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,6 +31,12 @@ 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+
3440 Delete = new RelayCommand < Task > ( taskToRemove =>
3541 {
3642 Tasks . Remove ( taskToRemove ! ) ;
@@ -40,6 +46,7 @@ public TaskListViewModel(
4046
4147 public ICommand Add { get ; }
4248
49+ public ICommand Edit { get ; }
4350 public ICommand Delete { get ; }
4451
4552 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>
149 <Grid >
1510 <StackPanel >
1611 <StackPanel Orientation =" Horizontal" >
2318 <DataTemplate DataType =" {x:Type domain:Task}" >
2419 <StackPanel Orientation =" Horizontal" >
2520 <TextBlock Text =" {Binding Name}" />
21+ <Button Content =" Edit"
22+ Command =" {Binding DataContext.Edit, ElementName=Root}"
23+ CommandParameter =" {Binding}" />
2624 <Button Content =" Delete"
2725 Command =" {Binding DataContext.Delete, ElementName=Root}"
2826 CommandParameter =" {Binding}" />
Original file line number Diff line number Diff line change 11using System . Windows . Controls ;
2- using System . Windows . Input ;
32using Desktop . Tasks ;
4- using Task = Desktop . Domain . Task ;
53
64namespace Desktop . Project ;
75
@@ -18,13 +16,4 @@ public TasksList(TaskListViewModel viewModel)
1816 viewModel . TaskCreationViewCreator = creationViewModel =>
1917 new TaskCreation ( creationViewModel ) ;
2018 }
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- }
3019}
Original file line number Diff line number Diff line change 11using System . Windows ;
2+ using Desktop . Common ;
23using Task = Desktop . Domain . Task ;
34
45namespace Desktop . Tasks ;
You can’t perform that action at this time.
0 commit comments