Exemplo n.º 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);
        }
 // 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);
 }