I am having a hard time obtaining information about an object's indexer through the TypeDescriptor - just to be sure, I mean that kind of thing:
class ComponentWithIndexer
{
public string this[int i]
{
get { return "hello"; }
}
}
Since you can influence Binding in WPF with customizing Typedescriptors and since you can bind to indexers in WPF ( e.g. {Binding [12] ) I was wondering whether information on Indexers is also available through a Type descriptor.
So, where does the info hide, and if it doesn't hide there, how does the WPF Binding against indexers work?
Short answer, no - you can't get at indexers via
TypeDescriptorLonger answer - why you can't - deep down in the bowels of the
TypeDescriptormess-o-classes, there is the reflective call to aggregate properties for theGetPropertiescall. In there is this code:The important part there is the check for 0 index parameters - if it has an indexer, it skips it. :(