Ejemplo n.º 1
0
        // Token: 0x060056D1 RID: 22225 RVA: 0x00180420 File Offset: 0x0017E620
        private static void OnIsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TabItem    tabItem          = d as TabItem;
            bool       flag             = (bool)e.NewValue;
            TabControl tabControlParent = tabItem.TabControlParent;

            if (tabControlParent != null)
            {
                tabControlParent.RaiseIsSelectedChangedAutomationEvent(tabItem, flag);
            }
            if (flag)
            {
                tabItem.OnSelected(new RoutedEventArgs(Selector.SelectedEvent, tabItem));
            }
            else
            {
                tabItem.OnUnselected(new RoutedEventArgs(Selector.UnselectedEvent, tabItem));
            }
            if (flag)
            {
                Binding binding = new Binding("Margin");
                binding.Source = tabItem;
                BindingOperations.SetBinding(tabItem, KeyboardNavigation.DirectionalNavigationMarginProperty, binding);
            }
            else
            {
                BindingOperations.ClearBinding(tabItem, KeyboardNavigation.DirectionalNavigationMarginProperty);
            }
            tabItem.UpdateVisualState();
        }
Ejemplo n.º 2
0
        private static void OnIsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TabItem tabItem = d as TabItem;

            bool isSelected = (bool)e.NewValue;

            TabControl parentTabControl = tabItem.TabControlParent;

            if (parentTabControl != null)
            {
                parentTabControl.RaiseIsSelectedChangedAutomationEvent(tabItem, isSelected);
            }

            if (isSelected)
            {
                tabItem.OnSelected(new RoutedEventArgs(Selector.SelectedEvent, tabItem));
            }
            else
            {
                tabItem.OnUnselected(new RoutedEventArgs(Selector.UnselectedEvent, tabItem));
            }


            // KeyboardNavigation use bounding box reduced with DirectionalNavigationMargin when calculating the next element in directional navigation
            // Because TabItem use negative margins some TabItems overlap which would changes the directional navigation if we don't reduce the bounding box
            if (isSelected)
            {
                Binding binding = new Binding("Margin");
                binding.Source = tabItem;
                BindingOperations.SetBinding(tabItem, KeyboardNavigation.DirectionalNavigationMarginProperty, binding);
            }
            else
            {
                BindingOperations.ClearBinding(tabItem, KeyboardNavigation.DirectionalNavigationMarginProperty);
            }

            tabItem.UpdateVisualState();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// IsSelected changed handler
        /// </summary>
        /// <param name="d">TabItem that changed IsSelected.</param>
        /// <param name="e">DependencyPropertyChangedEventArgs.</param>
        private static void OnIsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TabItem tabItem = d as TabItem;

            Debug.Assert(tabItem != null);

            bool isSelected = (bool)e.NewValue;

            RoutedEventArgs args = new RoutedEventArgs();

            if (isSelected)
            {
                tabItem.OnSelected(args);
            }
            else
            {
                tabItem.OnUnselected(args);
            }

            // fire the IsSelectedChanged event for automation
            if (AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementSelected))
            {
                TabControl parentSelector = tabItem.TabControlParent;
                if (parentSelector != null)
                {
                    TabItemAutomationPeer tabItemPeer = GetTabItemAutomationPeer(tabItem);
                    if (tabItemPeer != null)
                    {
                        tabItemPeer.RaiseAutomationIsSelectedChanged(isSelected);
                    }
                }
            }

            tabItem.IsTabStop = isSelected;
            tabItem.UpdateVisualState();
        }