title: How to delete an Item from Sqlite & List from Xamarin
body: <p>I got a big problem. I have got a list in Sqlite and I want to delete an item by menuitem clicked event. the code:</p>
  
  <pre><code> async void MenuItem_Clicked(object sender, EventArgs e)
          {
              var nahrungsmittel = _nahrungsmittel[0];
              await _connection.DeleteAsync(nahrungsmittel);
              _nahrungsmittel.Remove(nahrungsmittel);
  
          }
  </code></pre>
  
  <p>For now its only deleting the first object in the observable collection and in db. how can I get delete the one I tapped on? There´s some more code if this should not be enough:</p>
  
  <pre><code>namespace EssenBestellen.Speisen
  {
      [XamlCompilation(XamlCompilationOptions.Compile)]
      public partial class SpeisenUebersicht : ContentPage
      {
  
      private SQLiteAsyncConnection _connection;
      private ObservableCollection&lt;Nahrungsmittel&gt; _nahrungsmittel;
  
      public SpeisenUebersicht()
      {
          BindingContext = new 
  EssenBestellen.ViewModels.NahrungsmittelListeViewModel(new 
  EssenBestellen.ViewModels.PageService());
          InitializeComponent();
  
          _connection = DependencyService.Get&lt;ISQLiteDb&gt;().GetConnection();
  
      }
  
       async protected override void OnAppearing()
       {
           await _connection.CreateTableAsync&lt;Nahrungsmittel&gt;();
  
           var nahrungsmittel = await _connection.QueryAsync&lt;Nahrungsmittel&gt; 
  ("SELECT * FROM Nahrungsmittel ORDER BY NAME ASC"); //.ToListAsync();
           _nahrungsmittel = new ObservableCollection&lt;Nahrungsmittel&gt; 
    (nahrungsmittel);
          speisenListe.ItemsSource = _nahrungsmittel;
  
  
          base.OnAppearing();
      }
  
      async void Add_Clicked(object sender, EventArgs e)
      {
          await Navigation.PushAsync(new SpeisenAdd());
      }
  
      async void MenuItem_Clicked(object sender, EventArgs e)
      {
          var nahrungsmittel = _nahrungsmittel[0];
          await _connection.DeleteAsync(nahrungsmittel);
          _nahrungsmittel.Remove(nahrungsmittel);
  
      }
  
  
      private void speisenListe_ItemSelected(object sender, 
  SelectedItemChangedEventArgs e)
      {
  
      (BindingContext as 
  
  
  
  
  
  
  EssenBestellen.ViewModels.NahrungsmittelListeViewModel).SelectNahrungsmittel(e.S 
  
  
  
    electedItem as Nahrungsmittel);
  
      }
  
      private void MenuItem_Clicked_1(object sender, EventArgs e)
      {
          DisplayAlert("Kommt Noch","noch nicht implementiert", "OK");
  
      }
  
  
  }
  }
  </code></pre>
  
  <p><strong>Xaml file Update</strong></p>
  
  <pre><code>&lt;ContentPage.ToolbarItems&gt;
  &lt;ToolbarItem Icon="plus.png" Text="Neu" Activated="Add_Clicked"/&gt;
  &lt;/ContentPage.ToolbarItems&gt;
  
  &lt;StackLayout&gt;
  
  &lt;ListView x:Name="speisenListe" HasUnevenRows="True" ItemsSource="{Binding Nahrungsmittels}" SelectedItem="{Binding SelectedNahrungsmittel, Mode=TwoWay}" ItemTapped="speisenListe_ItemTapped" ItemSelected="speisenListe_ItemSelected"&gt;
      &lt;ListView.ItemTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;ViewCell&gt;
                  &lt;ViewCell.ContextActions&gt;
                      &lt;MenuItem Text="Bearbeiten" IsDestructive="False" Clicked="MenuItem_Clicked"  Command="{Binding .}" /&gt;
                      &lt;MenuItem Text="Löschen" IsDestructive="True" Clicked="MenuItem_Clicked"  Command="{Binding .}" /&gt;
                  &lt;/ViewCell.ContextActions&gt;
                  &lt;StackLayout Orientation="Horizontal" Padding="5"&gt;
                      &lt;Label Text="{Binding Id}" HorizontalOptions="StartAndExpand"/&gt;
                      &lt;Label Text="{Binding Name}" TextColor="Gray" HorizontalOptions="CenterAndExpand"/&gt;
                      &lt;Label Text="{Binding Preis}" TextColor="Gray" HorizontalOptions="EndAndExpand"/&gt;
                  &lt;/StackLayout&gt;
              &lt;/ViewCell&gt;
          &lt;/DataTemplate&gt;
      &lt;/ListView.ItemTemplate&gt;
  &lt;/ListView&gt;
  </code></pre>
  
  <p></p>