Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Say i am binding to an ArrayList. The ArrayList contains a group of ObjectA's defined, loosely, as the following:

 

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

Posted

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...

 

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?

Anybody looking for a graduate programmer (Midlands, England)?
Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...