/// <summary>Indicates that the <see cref="P:System.Windows.Controls.Panel.IsItemsHost" /> property value has changed.</summary>
        /// <param name="oldIsItemsHost">The old property value.</param>
        /// <param name="newIsItemsHost">The new property value.</param>
        // Token: 0x060052E7 RID: 21223 RVA: 0x00171508 File Offset: 0x0016F708
        protected virtual void OnIsItemsHostChanged(bool oldIsItemsHost, bool newIsItemsHost)
        {
            DependencyObject itemsOwnerInternal = ItemsControl.GetItemsOwnerInternal(this);
            ItemsControl     itemsControl       = itemsOwnerInternal as ItemsControl;
            Panel            panel = null;

            if (itemsControl != null)
            {
                IItemContainerGenerator itemContainerGenerator = itemsControl.ItemContainerGenerator;
                if (itemContainerGenerator != null && itemContainerGenerator == itemContainerGenerator.GetItemContainerGeneratorForPanel(this))
                {
                    panel = itemsControl.ItemsHost;
                    itemsControl.ItemsHost = this;
                }
            }
            else
            {
                GroupItem groupItem = itemsOwnerInternal as GroupItem;
                if (groupItem != null)
                {
                    IItemContainerGenerator generator = groupItem.Generator;
                    if (generator != null && generator == generator.GetItemContainerGeneratorForPanel(this))
                    {
                        panel = groupItem.ItemsHost;
                        groupItem.ItemsHost = this;
                    }
                }
            }
            if (panel != null && panel != this)
            {
                panel.VerifyBoundState();
            }
            this.VerifyBoundState();
        }
Exemple #2
0
        /// <summary>
        ///     This method is invoked when the IsItemsHost property changes.
        /// </summary>
        /// <param name="oldIsItemsHost">The old value of the IsItemsHost property.</param>
        /// <param name="newIsItemsHost">The new value of the IsItemsHost property.</param>
        protected virtual void OnIsItemsHostChanged(bool oldIsItemsHost, bool newIsItemsHost)
        {
            // GetItemsOwner will check IsItemsHost first, so we don't have
            // to check that IsItemsHost == true before calling it.
            DependencyObject parent       = ItemsControl.GetItemsOwnerInternal(this);
            ItemsControl     itemsControl = parent as ItemsControl;
            Panel            oldItemsHost = null;

            if (itemsControl != null)
            {
                // ItemsHost should be the "root" element which has
                // IsItemsHost = true on it.  In the case of grouping,
                // IsItemsHost is true on all panels which are generating
                // content.  Thus, we care only about the panel which
                // is generating content for the ItemsControl.
                IItemContainerGenerator generator = itemsControl.ItemContainerGenerator as IItemContainerGenerator;
                if (generator != null && generator == generator.GetItemContainerGeneratorForPanel(this))
                {
                    oldItemsHost           = itemsControl.ItemsHost;
                    itemsControl.ItemsHost = this;
                }
            }
            else
            {
                GroupItem groupItem = parent as GroupItem;
                if (groupItem != null)
                {
                    IItemContainerGenerator generator = groupItem.Generator as IItemContainerGenerator;
                    if (generator != null && generator == generator.GetItemContainerGeneratorForPanel(this))
                    {
                        oldItemsHost        = groupItem.ItemsHost;
                        groupItem.ItemsHost = this;
                    }
                }
            }

            if (oldItemsHost != null && oldItemsHost != this)
            {
                // when changing ItemsHost panels, disconnect the old one
                oldItemsHost.VerifyBoundState();
            }

            VerifyBoundState();
        }