views:

2207

answers:

2

I'm using the WPF toolkit datagrid.

How can I get the values of the cells of the selected rows?

Thanks

+3  A: 

In WPF rows represent objects in a list and columns are object's properties.

It depends on what DataGrid.ItemsSource is.If your ItemSource is an array of BindedClass you could get selected object by:

BindedClass bc = (BindedClass)dataGridControl.SelectedItem;
var prop1 = bc.Prop1;
var prop2 = bc.Prop2;
ArsenMkrt
Ok, I got it. The problem was that I retrieve the info from the DB using Linq, and I did it using anonymous types. But you gave me the clue to find my mistake explaining me how the datagrid works. Thanks!
Jonathan
A: 

How can I do that if my datagrid.ItemSource is bindin with a LINQ query

Lebouz