Exemple #1
0
        private static object CoerceIsSubmenuOpen(DependencyObject d, object value)
        {
            if ((bool)value)
            {
                MenuItemNew item = (MenuItemNew)d;

                if (item.Role == MenuItemRole.SubmenuHeader)
                {
                    if (item.IsMenuItemExpanded)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }

                if (!item.IsLoaded)
                {
                    item.Loaded += (s, e) =>
                    {
                        Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Input, new DispatcherOperationCallback(delegate(object param)
                        {
                            item.CoerceValue(MenuItemNew.IsSubmenuOpenProperty);
                            return(null);
                        }), null);
                    };
                    return(false);
                }
            }
            return(value);
        }
Exemple #2
0
        void MenuItemNew_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            MenuItemNew item = sender as MenuItemNew;

            if (item.Role == MenuItemRole.SubmenuHeader)
            {
                IsMenuItemExpanded = !IsMenuItemExpanded;
                IsSubmenuOpen      = IsMenuItemExpanded;
            }
        }
Exemple #3
0
        void MenuItemNew_LostFocus(object sender, RoutedEventArgs e)
        {
            MenuItemNew item = sender as MenuItemNew;

            item.IsMenuItemExpanded = false;
        }