TabPanel
Inheritance: System.Windows.Controls.Panel, IScrollInfo
Example #1
0
        /// <summary>
        /// OnMinMaxChanged callback responds to any of the Min/Max dependency properties changing
        /// </summary>
        /// <param name="d"></param>
        /// <param name="e"></param>
        private static void OnMinMaxChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TabControl tc = (TabControl)d;

            if (tc.Template == null)
            {
                return;
            }

            foreach (TabItem child in tc.InternalChildren())
            {
                if (child != null)
                {
                    child.Dimension = null;
                }
            }

            TabPanel tp = Helper.FindVirtualizingTabPanel(tc);

            if (tp != null)
            {
                tp.InvalidateMeasure();
            }
        }
Example #2
0
        protected override void OnPreviewKeyDown(KeyEventArgs e)
        {
            var tabsCount = GetTabsCount();

            if (tabsCount == 0)
            {
                return;
            }

            TabItem ti = null;

            switch (e.Key)
            {
            case Key.Home:
                ti = GetTabItem(0);
                break;

            case Key.End:
                ti = GetTabItem(tabsCount - 1);
                break;

            case Key.Tab:
                if (e.KeyboardDevice.Modifiers == ModifierKeys.Control)
                {
                    var index     = SelectedIndex;
                    var direction = e.KeyboardDevice.Modifiers == ModifierKeys.Shift ? -1 : 1;

                    while (true)
                    {
                        index += direction;
                        if (index < 0)
                        {
                            index = tabsCount - 1;
                        }
                        else if (index > tabsCount - 1)
                        {
                            index = 0;
                        }

                        FrameworkElement ui = GetTabItem(index);
                        if (ui != null)
                        {
                            if (ui.Visibility == Visibility.Visible && ui.IsEnabled)
                            {
                                ti = GetTabItem(index);
                                break;
                            }
                        }
                    }
                }
                break;
            }

            TabPanel panel = Helper.FindVirtualizingTabPanel(this);

            if (panel != null && ti != null)
            {
                panel.MakeVisible(ti, Rect.Empty);
                SelectedItem = ti;

                e.Handled = ti.Focus();
            }
            base.OnPreviewKeyDown(e);
        }