TL;DR: if a
DataGrid
cell is bound to a specific object (not string, int, ...), how can I access it in converter or setter?
You can't really store the Person
object in the DataRow
. You can confirm this yourself:
var dr = dt.NewRow();
//set the Name column to a Person object
dr["Name"] = new Person(name, age >= 18);
//...and retrieve it. It is now a string:
var thePerson = dr["Name"] as string;
Mixing an object model with a DataTable
is not a good idea. You should replace the DataTable
with a collection of custom objects. Then you will be able to use a value converter or a DataTrigger
to set the Background
property of the cell.