public static void UpdateItemsSource(this TCollectionView platformView, ItemsView view) { if (view.ItemsSource is INotifyCollectionChanged collectionChanged) { if (_observableSource != null) { _observableSource.CollectionChanged -= OnCollectionChanged; } _observableSource = collectionChanged; _observableSource.CollectionChanged += OnCollectionChanged; } UpdateAdaptor(platformView, view); void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (view.ItemsSource == null || !view.ItemsSource.Cast <object>().Any()) { platformView.Adaptor = EmptyItemAdaptor.Create(view); } else { if (platformView.Adaptor is EmptyItemAdaptor) { platformView.UpdateAdaptor(view); } } } }
void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (Element.ItemsSource == null || !Element.ItemsSource.Cast <object>().Any()) { Control.Adaptor = EmptyItemAdaptor.Create(Element); } else { if (Control.Adaptor is EmptyItemAdaptor) { UpdateAdaptor(false); } } }
public static void UpdateAdaptor(this TCollectionView platformView, ItemsView view) { if (view.ItemsSource == null || !view.ItemsSource.Cast <object>().Any()) { platformView.Adaptor = EmptyItemAdaptor.Create(view); } else if (view.ItemTemplate == null) { platformView.Adaptor = new ItemDefaultTemplateAdaptor(view); } else { platformView.Adaptor = new ItemTemplateAdaptor(view); } platformView.Adaptor.ItemSelected += OnItemSelected; }
protected void UpdateAdaptor(bool initialize) { if (!initialize) { if (Element.ItemsSource == null || !Element.ItemsSource.Cast <object>().Any()) { Control.Adaptor = EmptyItemAdaptor.Create(Element); } else if (Element.ItemTemplate == null) { Control.Adaptor = new ItemDefaultTemplateAdaptor(Element); } else { Control.Adaptor = new ItemTemplateAdaptor(Element); Control.Adaptor.ItemSelected += OnItemSelectedFromUI; } } }