I'm not sure exactly what your requirements are, especially the bit about ToList
not doing what you need.
Unfortunately, BindingList<T>
only accepts an IList<T>
parameter in its constructor and not an IEnumerable<T>
.
However, if you implement a pass-through constructor on your custom collection (or if it already has a constructor that takes IList<T>
) then you could do something similar to this:
public class MyListObject<T> : BindingList<T>
{
public MyListObject() : base() { }
public MyListObject(IList<T> list) : base(list) { }
}
// ...
MyListObject<int> yourList = new MyListObject<int> { 1, 2, 3, 4, 5 };
yourList = new MyListObject<int>(yourList.Select(s => s * 2).ToList());
// yourList now contains 2, 4, 6, 8, 10