Пример #1
0
        protected virtual void SetItemsSource(IEnumerable value)
        {
            if (Object.ReferenceEquals(_itemsSource, value) &&
                !ReloadOnAllItemsSourceSets)
            {
                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();
        }
Пример #2
0
        protected virtual void SetItemsSource(IEnumerable value)
        {
            if (Object.ReferenceEquals(this._itemsSource, value) &&
                !this.ReloadOnAllItemsSourceSets)
            {
                return;
            }

            if (this._subscription != null)
            {
                this._subscription.Dispose();
                this._subscription = null;
            }

            this._itemsSource = value;

            if (this._itemsSource != null && !(this._itemsSource is IList))
            {
                MvxBindingTrace.Trace(MvxTraceLevel.Warning,
                                      "You are currently binding to IEnumerable - this can be inefficient, especially for large collections. Binding to IList is more efficient.");
            }

            var newObservable = this._itemsSource as INotifyCollectionChanged;

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