Here’s some code for ItemsSource:
public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create( nameof(ItemsSource), typeof(IEnumerable), typeof(MyControl), null, BindingMode.OneWay, propertyChanged: (bindable, oldValue, newValue) => OnItemsSourceChanged(bindable, oldValue, newValue)); static void OnItemsSourceChanged(BindableObject bindable, object oldValue, object newValue) { void newValueINotifyCollectionChanged_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { var wraplayout = bindable as WrapLayout; if (e.OldItems != null) foreach (var item in e.OldItems) wraplayout.Children.Remove(item as View); if (e.NewItems != null) foreach (var item in e.NewItems) wraplayout.Children.Add(item as View); } var oldValueINotifyCollectionChanged = oldValue as INotifyCollectionChanged; if (null != oldValueINotifyCollectionChanged) { oldValueINotifyCollectionChanged.CollectionChanged -= newValueINotifyCollectionChanged_CollectionChanged; } var newValueINotifyCollectionChanged = newValue as INotifyCollectionChanged; if (null != newValueINotifyCollectionChanged) { newValueINotifyCollectionChanged.CollectionChanged += newValueINotifyCollectionChanged_CollectionChanged; } } public IEnumerable ItemsSource { get { return (IEnumerable)GetValue(ItemsSourceProperty); } set { SetValue(ItemsSourceProperty, value); } }
what is WrapLayout?