I have a binding of the form:
Path=SpecialCollection[0]
The SpecialCollection class extends ObservableCollection and has an indexer property.
public T this[string propertyValue]
{
get
{
// do stuff
return default(T);
}
}
My problem is that the binding attempts to get the indexer property value, instead of returning the 0th item in the collection. Is there a way to force the binding to treat 0 as an integer so it returns a collection element, instead of invoking the collection’s indexer property’s getter?
According to MSDN you can tell the binding the type of the value entered as index:
I noticed that the
Bindingconstructor taking a path string uses anotherPropertyPathconstructor than the defaultPropertyPathtype converter, saidPropertyPathconstructor does not work in this scenario. To avoid the problem avoid theBindingconstructor by setting thePathproperty manually which invokes the conversion via type converter.