Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3166
Binding to objects that contain other objects
posted

I want to show the contain object at the same level as main object. Is there are way to achieve this.

public class ClassA
{
    public string Field1 { get; set; }
    public string Field2 { get; set; }
    public ClassB { get; set; }
}

public class ClassB
{
    public string Field3 {get; set; }
}

I want Field1, Field2, Field3 to appear at the same level.

PS: I found the post with this subject in WPF forum, the example comes from that post :-)

Parents
  • 17259
    Verified Answer
    Offline posted

    If you can, add this property in classA:

    public string Field3

    {

    get { return classB.Field3; }

    set { classB.Field3 = value; }

    }

    If you can't, add an unbound column named Field3 and in InitializeRow event write this:

    var item = e.Row.ListObject as ClassA;

    e.Row.Cells["Field3"].Value = item.classB.Field3;

Reply Children