Jonathan
Jonathan

Reputation: 12025

WPF Datagrid. Get the values of each cell of the selected row

I'm using the WPF toolkit DataGrid.

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

Upvotes: 3

Views: 13335

Answers (1)

Arsen Mkrtchyan
Arsen Mkrtchyan

Reputation: 50712

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:

BoundClass bc = (BoundClass)dataGridControl.SelectedItem;
var prop1 = bc.Prop1;
var prop2 = bc.Prop2;

Upvotes: 8

Related Questions