コード例 #1
0
        // Token: 0x06005E09 RID: 24073 RVA: 0x001A7084 File Offset: 0x001A5284
        private static void ColumnsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            GridViewRowPresenterBase gridViewRowPresenterBase = (GridViewRowPresenterBase)d;
            GridViewColumnCollection gridViewColumnCollection = (GridViewColumnCollection)e.OldValue;

            if (gridViewColumnCollection != null)
            {
                InternalCollectionChangedEventManager.RemoveHandler(gridViewColumnCollection, new EventHandler <NotifyCollectionChangedEventArgs>(gridViewRowPresenterBase.ColumnCollectionChanged));
                if (!gridViewColumnCollection.InViewMode && gridViewColumnCollection.Owner == gridViewRowPresenterBase.GetStableAncester())
                {
                    gridViewColumnCollection.Owner = null;
                }
            }
            GridViewColumnCollection gridViewColumnCollection2 = (GridViewColumnCollection)e.NewValue;

            if (gridViewColumnCollection2 != null)
            {
                InternalCollectionChangedEventManager.AddHandler(gridViewColumnCollection2, new EventHandler <NotifyCollectionChangedEventArgs>(gridViewRowPresenterBase.ColumnCollectionChanged));
                if (!gridViewColumnCollection2.InViewMode && gridViewColumnCollection2.Owner == null)
                {
                    gridViewColumnCollection2.Owner = gridViewRowPresenterBase.GetStableAncester();
                }
            }
            gridViewRowPresenterBase.NeedUpdateVisualTree = true;
            gridViewRowPresenterBase.InvalidateMeasure();
        }
コード例 #2
0
        //-------------------------------------------------------------------
        //
        // Private Methods / Properties / Fields
        //
        //-------------------------------------------------------------------

        #region Private Methods / Properties / Fields

        // Property invalidation callback invoked when ColumnCollectionProperty is invalidated
        private static void ColumnsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            GridViewRowPresenterBase c = (GridViewRowPresenterBase)d;

            GridViewColumnCollection oldCollection = (GridViewColumnCollection)e.OldValue;

            if (oldCollection != null)
            {
                InternalCollectionChangedEventManager.RemoveHandler(oldCollection, c.ColumnCollectionChanged);

                // NOTE:
                // If the collection is NOT in view mode (a.k.a owner isn't GridView),
                // RowPresenter is responsible to be or to find one to be the collection's mentor.
                //
                if (!oldCollection.InViewMode && oldCollection.Owner == c.GetStableAncester())
                {
                    oldCollection.Owner = null;
                }
            }

            GridViewColumnCollection newCollection = (GridViewColumnCollection)e.NewValue;

            if (newCollection != null)
            {
                InternalCollectionChangedEventManager.AddHandler(newCollection, c.ColumnCollectionChanged);

                // Similar to what we do to oldCollection. But, of course, in a reverse way.
                if (!newCollection.InViewMode && newCollection.Owner == null)
                {
                    newCollection.Owner = c.GetStableAncester();
                }
            }

            c.NeedUpdateVisualTree = true;
            c.InvalidateMeasure();
        }