Microsoft.Windows.Controls.Ribbon.RibbonMenuButton.OnIsSelectedChanged C# (CSharp) Метод

OnIsSelectedChanged() приватный статический Метод

Called when IsSelected changed on this element or any descendant.
private static OnIsSelectedChanged ( object sender, RoutedPropertyChangedEventArgs e ) : void
sender object
e RoutedPropertyChangedEventArgs
Результат void
        private static void OnIsSelectedChanged(object sender, RoutedPropertyChangedEventArgs<bool> e)
        {
            FrameworkElement selectionItem = e.OriginalSource as FrameworkElement;

            if (selectionItem != null)
            {
                RibbonMenuButton menu = (RibbonMenuButton)sender;

                // If the selected item is a child of ours, make it the current selection.
                // If the selection changes from a menu item with its submenu
                // open to another then close the old selection's submenu.
                if (e.NewValue)
                {
                    ItemsControl parentItemsControl = ItemsControl.ItemsControlFromItemContainer(selectionItem);
                    if (menu == parentItemsControl)
                    {
                        menu.CurrentSelection = selectionItem;
                    }
                }
                else
                {
                    // As in MenuItem.OnIsSelectedChanged, if the item is deselected
                    // and it's our current selection, set CurrentSelection to null.
                    if (menu.CurrentSelection == selectionItem)
                    {
                        menu.CurrentSelection = null;
                    }
                }

                e.Handled = true;
            }
        }