コード例 #1
0
        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        internal override void AttachDataItem()
        {
            // If there is an XPath, we get a context node for running queries by
            // creating a view from DataItem and using its CurrentItem.
            // If DataItem isn't a valid collection, it's probably an XmlNode,
            // in which case we will try using DataItem directly as the ContextNode

            if (XPath.Length > 0)
            {
                CollectionView = DataItem as CollectionView;

                if (CollectionView == null && DataItem is ICollection)
                {
                    CollectionView = CollectionViewSource.GetDefaultCollectionView(DataItem, TargetElement);
                }
            }

            if (CollectionView != null)
            {
                CurrentChangedEventManager.AddHandler(CollectionView, ParentBindingExpression.OnCurrentChanged);

                if (IsReflective)
                {
                    CurrentChangingEventManager.AddHandler(CollectionView, ParentBindingExpression.OnCurrentChanging);
                }
            }

            // Set ContextNode and hook events
            UpdateContextNode(true);
        }
コード例 #2
0
 // Token: 0x06007727 RID: 30503 RVA: 0x00220C9C File Offset: 0x0021EE9C
 internal override void DetachDataItem()
 {
     if (this.CollectionView != null)
     {
         CurrentChangedEventManager.RemoveHandler(this.CollectionView, new EventHandler <EventArgs>(base.ParentBindingExpression.OnCurrentChanged));
         if (base.IsReflective)
         {
             CurrentChangingEventManager.RemoveHandler(this.CollectionView, new EventHandler <CurrentChangingEventArgs>(base.ParentBindingExpression.OnCurrentChanging));
         }
     }
     this.UpdateContextNode(false);
     this.CollectionView = null;
 }
コード例 #3
0
        /// <summary>
        /// Unhooks the current view from the weak listeners.
        /// </summary>
        /// <param name="iCollectionView">The view to be removed from the hooks.</param>
        void UnhookCollectionView(ICollectionView iCollectionView)
        {
            // The events of the given CollectionView are no longer of any interest to the public view of this object.
            CollectionChangedEventManager.RemoveListener(iCollectionView, this);
            CurrentChangingEventManager.RemoveListener(iCollectionView, this);
            CurrentChangedEventManager.RemoveListener(iCollectionView, this);

            // If the collection view had an opportunity to notify listeners when the property has changed then remove it to the weak listener.
            INotifyPropertyChanged iNotifyPropertyChanged = this.currentView as INotifyPropertyChanged;

            if (iNotifyPropertyChanged != null)
            {
                PropertyChangedEventManager.RemoveListener(iNotifyPropertyChanged, this, String.Empty);
            }
        }
コード例 #4
0
        /// <summary>
        /// Hooke the CollectionView into the current view.
        /// </summary>
        /// <param name="iCollectionView">The collection that is to become the underlying connection for this view.</param>
        void HookCollectionView(ICollectionView iCollectionView)
        {
            // Hook the class into the weak listeners.  The event handler will rebroadcast the events in the underlying collections to listeners of this object as
            // if they were generated from this class.
            CollectionChangedEventManager.AddListener(iCollectionView, this);
            CurrentChangingEventManager.AddListener(iCollectionView, this);
            CurrentChangedEventManager.AddListener(iCollectionView, this);

            // If the collection view has an opportunity to notify listeners when the property has changed then add it to the weak listener.
            INotifyPropertyChanged iNotifyPropertyChanged = this.currentView as INotifyPropertyChanged;

            if (iNotifyPropertyChanged != null)
            {
                PropertyChangedEventManager.AddListener(iNotifyPropertyChanged, this, String.Empty);
            }
        }
コード例 #5
0
        internal override void DetachDataItem()
        {
            //UnHook Collection Manager Currency notifications
            if (CollectionView != null)
            {
                CurrentChangedEventManager.RemoveHandler(CollectionView, ParentBindingExpression.OnCurrentChanged);

                if (IsReflective)
                {
                    CurrentChangingEventManager.RemoveHandler(CollectionView, ParentBindingExpression.OnCurrentChanging);
                }
            }

            // Set ContextNode (this unhooks events first)
            UpdateContextNode(false);

            CollectionView = null;
        }
コード例 #6
0
 // Token: 0x0600747B RID: 29819 RVA: 0x00215478 File Offset: 0x00213678
 internal void ReplaceCurrentItem(ICollectionView oldCollectionView, ICollectionView newCollectionView)
 {
     if (oldCollectionView != null)
     {
         CurrentChangedEventManager.RemoveHandler(oldCollectionView, new EventHandler <EventArgs>(base.ParentBindingExpression.OnCurrentChanged));
         if (base.IsReflective)
         {
             CurrentChangingEventManager.RemoveHandler(oldCollectionView, new EventHandler <CurrentChangingEventArgs>(base.ParentBindingExpression.OnCurrentChanging));
         }
     }
     if (newCollectionView != null)
     {
         CurrentChangedEventManager.AddHandler(newCollectionView, new EventHandler <EventArgs>(base.ParentBindingExpression.OnCurrentChanged));
         if (base.IsReflective)
         {
             CurrentChangingEventManager.AddHandler(newCollectionView, new EventHandler <CurrentChangingEventArgs>(base.ParentBindingExpression.OnCurrentChanging));
         }
     }
 }
コード例 #7
0
 // Token: 0x06007726 RID: 30502 RVA: 0x00220BF4 File Offset: 0x0021EDF4
 internal override void AttachDataItem()
 {
     if (this.XPath.Length > 0)
     {
         this.CollectionView = (base.DataItem as CollectionView);
         if (this.CollectionView == null && base.DataItem is ICollection)
         {
             this.CollectionView = CollectionViewSource.GetDefaultCollectionView(base.DataItem, base.TargetElement, null);
         }
     }
     if (this.CollectionView != null)
     {
         CurrentChangedEventManager.AddHandler(this.CollectionView, new EventHandler <EventArgs>(base.ParentBindingExpression.OnCurrentChanged));
         if (base.IsReflective)
         {
             CurrentChangingEventManager.AddHandler(this.CollectionView, new EventHandler <CurrentChangingEventArgs>(base.ParentBindingExpression.OnCurrentChanging));
         }
     }
     this.UpdateContextNode(true);
 }
コード例 #8
0
ファイル: CLRBindingWorker.cs プロジェクト: ash2005/z
        internal void ReplaceCurrentItem(ICollectionView oldCollectionView, ICollectionView newCollectionView)
        {
            // detach from old view
            if (oldCollectionView != null)
            {
                CurrentChangedEventManager.RemoveHandler(oldCollectionView, ParentBindingExpression.OnCurrentChanged);
                if (IsReflective)
                {
                    CurrentChangingEventManager.RemoveHandler(oldCollectionView, ParentBindingExpression.OnCurrentChanging);
                }
            }

            // attach to new view
            if (newCollectionView != null)
            {
                CurrentChangedEventManager.AddHandler(newCollectionView, ParentBindingExpression.OnCurrentChanged);
                if (IsReflective)
                {
                    CurrentChangingEventManager.AddHandler(newCollectionView, ParentBindingExpression.OnCurrentChanging);
                }
            }
        }