Example #1
0
        // Handles IsOpen property changing
        static void OnIsOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ContextMenu menu = (ContextMenu)d;

            if ((bool)e.NewValue)
            {
                if (menu.popup == null)
                {
                    // Creates new ribbon popup and prevents it`s closing
                    menu.isInInitializing = true;
                    menu.HookupParentPopup();
                    menu.isInInitializing = false;
                }
                Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new ThreadStart(delegate { menu.popup.Activate(); }));
            }
        }