How can I get the index of a selected item in my DataGrid in WPF?
I know that in WEB Forms I can get it like this:
MainGrid.Rows[e.RowIndex].Cells[0].Text
How can I get the index of a selected item in my DataGrid in WPF?
I know that in WEB Forms I can get it like this:
MainGrid.Rows[e.RowIndex].Cells[0].Text
Try this.
foreach (var item in MainGrid.SelectedItems)
{
this.SelectedProducts.Add((B.Product)item);
}
If I did not get it wrong ...
MainGrid.SelectedIndex
If you want to get the value of a selected item and store it in an attribute, try this example:
Usuario u = new Usuario();
u = DataGrid.SelectedItem as Usuario;
string nome = u.nome;