Rognik
Rognik

Reputation: 145

How to delete the selected item from listview(sqlite database) in windows phone 8.1

I inserted text items to the database. When I click on remove button the selected item is not removed from list view.

 private async void Button_Click_3(object sender, RoutedEventArgs e)
    {
        var dbpath = ApplicationData.Current.LocalFolder.Path + "/Mydb1.db";
        var con = new SQLiteAsyncConnection(dbpath);

        list l = new list();

        l.list1 = list_view.SelectedItem.ToString();       
        list_view.Items.Remove(l.list1);
        List<list> del = await con.QueryAsync<list>("delete from list where list1='" + list_view.SelectedItem + "'");
        if (del.Contains(list_view.SelectedItem))
        {
            list_view.Items.Remove(list_view.SelectedItem);
        }

(Here list1 is the column)

Upvotes: 0

Views: 669

Answers (1)

Dimitris Batsougiannis
Dimitris Batsougiannis

Reputation: 759

Try using ObservableCollection instead of List.

ObservableCollection implements the INotifyPropertyChanged interface which notifies the UI when something in the list is changed.

Upvotes: 1

Related Questions