Complex DataBinding

Sazlo

Newcomer
Joined
Oct 29, 2003
Messages
4
Say i am binding to an ArrayList. The ArrayList contains a group of ObjectA's defined, loosely, as the following:

Code:
public class ObjectA
{
    private ObjectB  objB;

    public ObjectB ContainedObject
    {
          get{return objB;}
    }
}

Is it possible to bind to a property of Object B? Ive tried using a binding string of "ContainedObject.SomeProperty" but obviously that doesnt work.

Any thoughts?
Saz
 
If you wish to return a property of a child object you can do something like the following, basically you just make a property of the type of the childs property...

C#:
public class ObjectA
{
	public string Name
	{
		get { return "Object A"; }
	}
}

public class ObjectB
{
	private ObjectA objA = new ObjectA();

	public string ObjAName
	{
		get { return objA.Name; }
	}
}

Does this answer your question?
 
Aye, thats what I've been doing as a work around. However, Id rather not take that approach if its possible. I find it a tad clunky since those exposed properties contain data that doesnt really apply to the object exposing them.

Ive thought along the lines of creating a "helperobject" to contain the necessary information for binding(including child object data) and have the parent create it when needed. I could achieve the same effect and keep the information logically seperated for processing. The helperobject would be a read only snapshot and strictly used for databinding. Perhaps thats a good way to go.

Any more input is greatly appreciated.

Thanks,
Saz
 
Back
Top