开发者

Data Binding In WPF

I have a an instance of class A;

class A
{
    ICollection<B> collec.....
}

class B
{
   C propC....;
}
class C
{
     string Name;
}

I pass instance as the datacontext to a Window and had set collec as ItemCollectionSource for the grid. Is it possible to display the Name property of C 开发者_开发问答in the DataGrid. Other properties are set if i give the Binding Property.

Thanks..


Nested properties can be referenced within a binding expression as such...

<TextBlock Text={Binding propC.Name} />

...where I'm assuming propC is indeed a publicly exposed property. You will also need to make sure that Name is also a publicly exposed property.


Make C.Name a property rather than a field, and bind on propC.Name


You are using private fields currently, try it with a public property instead.

class C
{
     public string Name {get;set;}
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜