diff --git a/ViewModels/MainWindowViewModel.cs b/ViewModels/MainWindowViewModel.cs index 9e297b4..3fff819 100644 --- a/ViewModels/MainWindowViewModel.cs +++ b/ViewModels/MainWindowViewModel.cs @@ -40,10 +40,7 @@ public void NewItem() Content = vm; } - public void RemoveItem() - { - Items.Items.Remove(Items.Items.ToList().Find(x => x.Name == Items.ItemSelected.Name)); - } + public void Save() { this.DB.Save(Items.Items); diff --git a/ViewModels/ToDoListViewModel.cs b/ViewModels/ToDoListViewModel.cs index c545973..8cda3a5 100644 --- a/ViewModels/ToDoListViewModel.cs +++ b/ViewModels/ToDoListViewModel.cs @@ -2,6 +2,8 @@ using System.Collections.ObjectModel; using ToDo.Models; using ReactiveUI; +using System.Reactive; +using System.Linq; namespace ToDo.ViewModels { @@ -11,6 +13,7 @@ public class ToDoListViewModel : ViewModelBase public ToDoListViewModel(IEnumerable items) { Items = new ObservableCollection(items); + } ToDoItem itemSelected; public ToDoItem ItemSelected @@ -22,7 +25,12 @@ public ToDoItem ItemSelected set { this.RaiseAndSetIfChanged(ref itemSelected, value); - } + } + + } + public void RemoveItem() + { + Items.Remove(Items.ToList().Find(x => x.Name == ItemSelected.Name)); } } } \ No newline at end of file diff --git a/Views/MainWindow.axaml.cs b/Views/MainWindow.axaml.cs index 67c6b70..0b04dc5 100644 --- a/Views/MainWindow.axaml.cs +++ b/Views/MainWindow.axaml.cs @@ -10,7 +10,7 @@ public MainWindow() { InitializeComponent(); this.Closing += delegate { ((MainWindowViewModel)this.DataContext).Save(); }; - } } + } } \ No newline at end of file diff --git a/Views/ToDoListView.axaml b/Views/ToDoListView.axaml index 8c7368d..3afa72a 100644 --- a/Views/ToDoListView.axaml +++ b/Views/ToDoListView.axaml @@ -14,7 +14,7 @@ - +