Example #1
0
        /// <summary>
        /// Removes the item from the view. If the item is one of the customizable items, then it is
        /// collapsed, if it is an item added to the QAT from the UI, it is removed from the Items collection.
        /// </summary>
        public void Remove(object item)
        {
            if (!Items.Contains(item))
            {
                var dp = item as DependencyObject;
                if (dp != null)
                {
                    item = ItemContainerGenerator.ItemFromContainer(dp);
                    if (item == null || !Items.Contains(item))
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }

            var customizable = CustomizableItems.Where(c => c.Item == item).FirstOrDefault();

            if (customizable != null)
            {
                customizable.Visibility = Visibility.Collapsed;
            }
            else
            {
                Items.Remove(item);
            }
        }
Example #2
0
        /// <summary>
        /// Overriding to ensure proper state.
        /// </summary>
        protected override void ClearContainerForItemOverride(DependencyObject element, object item)
        {
            base.ClearContainerForItemOverride(element, item);
            var customizable = CustomizableItems.Where(c => c.Item == item).FirstOrDefault();

            if (customizable != null)
            {
                customizable.PropertyChanged -= HandleCustomizableItemVisibilityChanged;
                CustomizableItems.Remove(customizable);
            }
        }