.net - Binding to a property of an object through object[property] rather than object.property -
i've read through wpf data binding overview , feel should possible can't quite make mental leap here. know if set binding's path foo, , set source obj, binding @ obj.foo. in other words, obj.__getattr__() accessed.
all want make @ obj[foo] instead. i'm using ironpython , in case obj class has overridden __getitem__() calls member function , returns value, why need functionality.
here above example written programmatically. displays foo property of obj in checkbox:
mybinding = binding("foo") mybinding.source = obj acheckbox.setbinding(checkbox.ischeckedproperty, mybinding) solution
it's simple this, apparently!
mybinding = binding("[foo]") mybinding.source = obj acheckbox.setbinding(checkbox.ischeckedproperty, mybinding)
you can use in binding, e.g. if datacontext/source has property
public string this[int i] { get{...} set{...} } you can create binding this:
<textblock text="{binding [0]}"/> edit: feel might have misunderstood question, if please tell me.
Comments
Post a Comment