Some parts of the WPF engine look for IList
, not IList<T>
. Since IList<T>
does not implement IList
, WPF is only aware that your list is IEnumerable
, not IList
. You should implement both interfaces. You should use explicit interface implementation to hide implementations that shouldn't be public on your object, e.g.
public class CustomList<T> : IList<T>, IList
{
// this is the one we want users of this class to use
public void Add(T value) { ... }
// IList's implementation; needs to exist, but this way it's hidden,
// unless you cast to IList
int IList.Add(object value) { this.Add((T)value); return this.Count - 1; }
// etc
}