Werewolve
Werewolve

Reputation: 2528

Binding to nested Property of Custom Object

I want to bind a column of my DataGrid to a nested property.

I have defined these two classes:

public class ViewObj
{
    public cCar car { get; set; }
    public string name { get; set; }
}

public class cCar
{
    public int ps { get; set; }
    public int wheels { get; set; }
}

The class cCar is a property of the class ViewObj.

I also have a List<ViewObj>, which I bind to my DataGrid.

I want bind the "wheels" property to the first column of the Datagrid.

How can I access the "wheels" property of the cCar class, that is part of the ViewObj class, from the DataGrid?

Thanks!

Upvotes: 1

Views: 529

Answers (1)

Aliostad
Aliostad

Reputation: 81660

Try

{Binding car.wheels}

Upvotes: 1

Related Questions