MvxBindableListView vnext monodroid: binding to any Collection #38

Alphapage opened this Issue Oct 15, 2012 · 4 comments


None yet

2 participants



It would be great to be able to bind MvxBindableListView to any Collection type.
I wanted to bind my monodroid ListView to a Dictionary<string,Type> but get an error: the problem is that the mvxbindablelistview expects an object that supports the IList interface.

I get around this problem using List<KeyValuePair<string,Type>>, but you can't get Dictionary tools in that case.

Thanks in advance for examining my request.

slodge commented Oct 15, 2012

This is interesting...

I'd never actually noticed that we don't support IEnumerable

I like the idea of supporting this - as it means 'any collection' will work.

However, there is a risk attached to this - if we support IEnumerable, then the list rendering could become very inefficient - e.g. when a ListView redraws item number 1001 in an IEnumerable, then it will need to use IEnumerable to access that item - rather than using the [] operator from IList.

I suspect I will add this support - but may include a warning to anyone using it. For small collections, then this should work fine, but as the collection grows in size, then IList is definitely recommended.

Thanks for the input - very interesting.


P.S. Good to hear that vNext is working for you on Droid!

@slodge slodge added a commit that closed this issue Oct 15, 2012
@slodge slodge IList to IEnumerable changes - attempts to fix #38 - includes a small…
… performance warning!
@slodge slodge closed this in 2b2be98 Oct 15, 2012
slodge commented Oct 15, 2012

OK.... you successfully distracted me.... :)

Just pushed a fix to try to address this.

The binding will now work with IEnumerables - but if you try this on large collections then performance will be slow - because Count(), ElementAt(position), etc will all require enumeration of the set.

For IList based collections, there is now a very small degradation in performance - but it will be very small.

Interested to know if this works for you (I tested it here with a modified Tutorial and it seemed to work OK for a five element Dictionary)

Thanks for the distraction :)


@slodge slodge reopened this Oct 15, 2012

Tested Dictionary<string,Type> on wp7 and monodroid without any problem.
Thanks for this quick implementation and hope to test it soon with monotouch, but I'm sure it will work as expected.

@Alphapage Alphapage closed this Oct 16, 2012
slodge commented Oct 16, 2012

Log the issue for MonoTouch when you get there -

I'm not on a Mac right now - so can't test and fix :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment