Ejemplo n.º 1
0
            protected virtual void SetItemsSource(IEnumerable value)
            {
                if (Equals(_itemsSource, value))
                {
                    return;
                }
                if (_subscription != null)
                {
                    _subscription.Dispose();
                    _subscription = null;
                }
                _itemsSource = value;
                if (_itemsSource != null && !(_itemsSource is IList))
                {
                    MvxBindingTrace.Trace(MvxTraceLevel.Warning,
                                          @"Binding to IEnumerable rather than IList - this can be inefficient, 
                                            especially for large lists");
                }
                var newObservable = _itemsSource as INotifyCollectionChanged;

                if (newObservable != null)
                {
                    _subscription = newObservable.WeakSubscribe(OnItemsSourceCollectionChanged);
                }
                NotifyDataSetChanged();
            }
        public void SetInternalItemsSource(IEnumerable itemsSourceEnumerable)
        {
            if (ReferenceEquals(_itemsSource, itemsSourceEnumerable) && !ReloadOnAllItemsSourceSets)
            {
                return;
            }

            _subscription?.Dispose();
            _subscription = null;

            _itemsSource = itemsSourceEnumerable ?? Enumerable.Empty <object>();

            if (_itemsSource != null && !(_itemsSource is IList))
            {
                MvxBindingTrace.Trace(MvxTraceLevel.Warning,
                                      "Binding to IEnumerable rather than IList - this can be inefficient, especially for large lists");
            }

            var newObservable = _itemsSource as INotifyCollectionChanged;

            if (newObservable != null)
            {
                _subscription = newObservable.WeakSubscribe(OnItemsSourceCollectionChanged);
            }

            OnItemsSourceCollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
        }