コード例 #1
0
        protected override void OnPropertyChanging(RadPropertyChangingEventArgs args)
        {
            base.OnPropertyChanging(args);
            if (args.Property != RadElement.VisibilityProperty || this.tabItems.Count <= 0)
            {
                return;
            }
            RadPageViewElement owner = (this.tabItems[0] as RadPageViewItem).Owner;

            if (owner == null)
            {
                throw new NullReferenceException(string.Format("{0} has no parent TabStrip", (object)this.tabItems[0].ToString()));
            }
            for (int index = 0; index < this.tabItems.Count; ++index)
            {
                (this.tabItems[index] as RadPageViewItem).Visibility = (ElementVisibility)args.NewValue;
            }
            if (this.TabItems.Contains((RadItem)(owner.SelectedItem as RibbonTab)))
            {
                foreach (RibbonTab ribbonTab in (IEnumerable <RadPageViewItem>)owner.Items)
                {
                    if (!this.TabItems.Contains((RadItem)ribbonTab))
                    {
                        owner.SelectedItem = (RadPageViewItem)ribbonTab;
                        break;
                    }
                }
            }
            owner.InvalidateMeasure();
            owner.InvalidateArrange();
            owner.UpdateLayout();
        }
コード例 #2
0
        protected override void OnPropertyChanging(RadPropertyChangingEventArgs args)
        {
            base.OnPropertyChanging(args);

            if (args.Property == RadItem.VisibilityProperty)
            {
                if (this.tabItems.Count > 0)
                {
                    RadPageViewElement tabStrip = (this.tabItems[0] as RadPageViewItem).Owner;

                    if (tabStrip == null)
                    {
                        throw new NullReferenceException(
                                  string.Format("{0} has no parent TabStrip", this.tabItems[0].ToString()));
                    }


                    for (int i = 0; i < this.tabItems.Count; i++)
                    {
                        RadPageViewItem currentTab = this.tabItems[i] as RadPageViewItem;
                        currentTab.Visibility = (ElementVisibility)args.NewValue;
                    }

                    if (this.TabItems.Contains(tabStrip.SelectedItem as RibbonTab))
                    {
                        foreach (RibbonTab tab in tabStrip.Items)
                        {
                            if (!this.TabItems.Contains(tab))
                            {
                                tabStrip.SelectedItem = tab;
                                break;
                            }
                        }
                    }

                    tabStrip.InvalidateMeasure();
                    tabStrip.InvalidateArrange();
                    tabStrip.UpdateLayout();
                }
            }
        }