/// <summary> /// Bind the items of a ListView to a collection. /// </summary> /// <typeparam name="T">The type of item in the collection.</typeparam> /// <param name="bindings">The binding manager.</param> /// <param name="control">The ListView to bind.</param> /// <param name="output">The collection to which to bind.</param> /// <param name="layoutId">The ID of the layout resource to use for the items of the ListView.</param> /// <param name="selection">Get the current selection.</param> /// <param name="selected">Set the current selection.</param> /// <param name="bind">The delegate that binds each item of the collection.</param> public static void BindItems <T>( this BindingManager bindings, ListView control, Func <IEnumerable <T> > output, int layoutId, Func <T> selection, Action <T> selected, Action <View, T, BindingManager> bind) { var adapter = new BindingArrayAdapter <T>(control, layoutId, selection, selected, bind); control.Adapter = adapter; bindings.Bind(() => output().ToList(), items => adapter.UpdateItems(items), adapter); }
public ItemContainer(T item, BindingArrayAdapter <T> adapter) { _item = item; _adapter = adapter; }