简体   繁体   English

绑定到自定义对象的嵌套属性

[英]Binding to nested Property of Custom Object

I want to bind a column of my DataGrid to a nested property. 我想将DataGrid的列绑定到嵌套属性。

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. cCar类是ViewObj类的属性。

I also have a List<ViewObj>, which I bind to my DataGrid. 我还有一个List <ViewObj>,它绑定到我的DataGrid。

I want bind the "wheels" property to the first column of the Datagrid. 我想将“ wheels”属性绑定到Datagrid的第一列。

How can I access the "wheels" property of the cCar class, that is part of the ViewObj class, from the DataGrid? 如何从DataGrid访问cCar类的“ wheels”属性,该属性是ViewObj类的一部分?

Thanks! 谢谢!

尝试

{Binding car.wheels}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM