Removing data from a SQLite database
In the last recipe of the current chapter, you will learn how to remove data from a particular table in the SQLite database.
As an example, you will introduce the last changes in the project from the previous recipe. You will do this by allowing a user to delete the currently selected entry.
Getting ready
To step through this recipe, you need the project from the previous recipe.
How to do it...
To modify the preceding example by introducing the feature of deleting a currently selected entry, perform the following steps:
Add the
CmdDelete
property, representing the command, to theMainViewModel
class in theMainViewModel.cs
file:public ICommand CmdDelete { get; set; }
Modify the constructor of the
MainViewModel
class in theMainViewModel.cs
file as follows:public MainViewModel() { (...) CmdDelete = new RelayCommand(() => Delete()); }
Add the
Delete
private method, which removes the currently selected entry...