[Gtk-sharp-list] Databindig IList to a Gtk.TreeView

Michael Hutchinson m.j.hutchinson at gmail.com
Sun Apr 23 16:12:38 EDT 2006


On 4/23/06, Philip Van Hoof <spam at pvanhoof.be> wrote:
> My implementation basically assumes the IList is a homogeneous list of
> objects that implement that property some way or another. As I cache the
> PropertyInfo instance, I'm not even sure it will work on a non
> homogeneous list where the property is enforced by an interface. But not
> caching the PropertyInfo would mean asking the reflection engine for
> that PropertyInfo on for all items the view will show (this is slower).
>
> ps. I basically need a pi.GetValue (instance, null) and a pi.SetValue
> (instance, value, null) where it would be nice if that "pi" can be
> cached. I'd need to search for the interface type to get the pi from,
> perhaps?

Will it work with a common base class? If so, I guess interfaces will
work too. I don't know, but I doubt it. According to MSDN, MemberInfo
classes have a DeclaringType property that is not necessarily the same
type that the MemberInfo was obtained from. However, you can't use the
DeclaringType to get a PropertyInfo from the base type, as any
overridden member is considered to 'redeclare' the member. I poked
around in Mono's class library as well, but stopped when I hit an
internal call.

If it doesn't work, you could require a System.Type in the ListAdaptor
constructor, then use that to get a base PropertyInfo. The System.Type
could then of course be an interface. I think this will work, though I
could be wrong.

> I can't spend extremely huge amounts of time on it. Perhaps working on
> all this is a fun task for a summer-of-code google student? It's just an
> idea of course.

GTK# databinding is already on the Mono SoC ideas page:
http://www.mono-project.com/StudentProjects#DataBinding

I'm afraid I'm applying for something else, sorry :(
It would be interesting to collect ideas for GTK# databinding anyway.
Maybe we need a wiki page somewhere.


Michael


More information about the Gtk-sharp-list mailing list