title: Delete Selected row from datagrid wpf c#
body: <p>I created a DataGrid. There are informations from database. i want delete selected row from datagrid and from database with button. i wrote these codes, program is running but when i click delete button there are Error "InvalidOperationException was unhandled". And what i must write my xaml file in datagrid tag ?  </p>
  
  <pre><code>private void button3_Click(object sender, RoutedEventArgs e)
      {
  
          var selectedItem = dataGrid1.SelectedItem;
          if (selectedItem != null)
          {
              dataGrid1.Items.Remove(selectedItem);
          }
  
      }
  </code></pre>