Ejemplo n.º 1
0
        // Return the object from which the given value was obtained, if possible
        internal override object GetSourceItem(object newValue)
        {
            BindingExpressionBase bindExpr = ActiveBindingExpression;

            if (bindExpr != null)
            {
                return(bindExpr.GetSourceItem(newValue));
            }
            return(true);
        }
        // Token: 0x06001C82 RID: 7298 RVA: 0x00086044 File Offset: 0x00084244
        internal override object GetSourceItem(object newValue)
        {
            BindingExpressionBase activeBindingExpression = this.ActiveBindingExpression;

            if (activeBindingExpression != null)
            {
                return(activeBindingExpression.GetSourceItem(newValue));
            }
            return(true);
        }
Ejemplo n.º 3
0
        void EnsureView(object source, Type collectionViewType)
        {
            if (_isInitializing || _deferLevel > 0)
            {
                return;
            }

            DataSourceProvider dataProvider = source as DataSourceProvider;

            // listen for DataChanged events from an DataSourceProvider
            if (dataProvider != _dataProvider)
            {
                if (_dataProvider != null)
                {
                    DataChangedEventManager.RemoveHandler(_dataProvider, OnDataChanged);
                }

                _dataProvider = dataProvider;

                if (_dataProvider != null)
                {
                    DataChangedEventManager.AddHandler(_dataProvider, OnDataChanged);
                    _dataProvider.InitialLoad();
                }
            }

            // if the source is DataSourceProvider, use its Data instead
            if (dataProvider != null)
            {
                source = dataProvider.Data;
            }

            // get the view
            ICollectionView view = null;

            if (source != null)
            {
                DataBindEngine engine     = DataBindEngine.CurrentDataBindEngine;
                ViewRecord     viewRecord = engine.GetViewRecord(source, this, collectionViewType, true,
                                                                 (object x) =>
                {
                    BindingExpressionBase beb = BindingOperations.GetBindingExpressionBase(this, SourceProperty);
                    return((beb != null) ? beb.GetSourceItem(x) : null);
                });

                if (viewRecord != null)
                {
                    view = viewRecord.View;
                    _isViewInitialized = viewRecord.IsInitialized;

                    // bring view up to date with the CollectionViewSource
                    if (_version != viewRecord.Version)
                    {
                        ApplyPropertiesToView(view);
                        viewRecord.Version = _version;
                    }
                }
            }

            // update the View property
            SetValue(ViewPropertyKey, view);
        }