c# – WPF – DataGrid – Delete

Question:

How can I get the index of a selected item in my DataGrid in WPF?

I know that on WEB Forms I can get it like this:

MainGrid.Rows[e.RowIndex].Cells[0].Text

Answer:

Try this.

foreach (var item in MainGrid.SelectedItems)
{
     this.SelectedProducts.Add((B.Product)item);
}
Scroll to Top