This is a migrated thread and some comments may be shown as answers.

Disable RadDock ContextMenu animation

2 Answers 130 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Michelle
Top achievements
Rank 1
Michelle asked on 20 Jun 2013, 06:08 PM
Hello,

I would like to disable the ContextMenu popup fade-in animation for a RadDock, but I cannot find where to do this.

I know how to disable the contextmenu animation for a RadGrid, for example, by subscribing to the grid's ContextMenuOpening event and using e.ContextMenu.AnimationEnabled = false; when the event fires.

However, the RadDock context menus are handled by the ContextMenuService, which only has the ContextMenuDisplaying event, and in this events handler, there is not a reference to the actual context menu object, just a list of the menuitems and the upcoming display position.

I know that ThemeResolutionService.AllowAnimations = false; will accomplish this, but this will also disable all animations across the application, which I do not want to do. I just want to disable the ContextMenu fade-in animation.

Any advice on how to do this?

Thanks,


Michelle

2 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Petrov
Telerik team
answered on 25 Jun 2013, 01:36 PM
Hi Michelle,

Thank you for writing.

You can disable the animation in RadDock by creating a custom ContextMenuService and overriding the method that shows the context menu. Then you have to register this service in the dock. Here is a code example of this:
this.radDock1.RegisterService(ServiceConstants.ContextMenu, new MyContextMenuService());
 
public class MyContextMenuService : ContextMenuService
{
    protected override void DisplayMenuCore(List<RadMenuItemBase> items, Point screenPos)
    {
        RadContextMenu currentMenu = new RadContextMenu();
        currentMenu.DropDown.AnimationEnabled = false;
        currentMenu.ThemeName = this.DockManager.ThemeName;
        currentMenu.DropDown.RightToLeft = this.DockManager.RightToLeft;
        currentMenu.DropDown.HorizontalPopupAlignment = (this.DockManager.RightToLeft == System.Windows.Forms.RightToLeft.Yes) ?
            HorizontalPopupAlignment.RightToRight : HorizontalPopupAlignment.LeftToLeft;
 
        foreach (RadItem item in items)
        {
            currentMenu.Items.Add(item);
        }
 
        currentMenu.Show(screenPos);
    }
}

I hope this will be useful. Should you have further questions, I would be glad to help.

Regards,
Ivan Petrov
Telerik
RadChart for WinForms is obsolete. Now what?
0
Michelle
Top achievements
Rank 1
answered on 28 Jun 2013, 01:35 AM
That is fantastic -- works like a charm! Thank you so much for the great support and plug 'n play code.


Michelle
Tags
Dock
Asked by
Michelle
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Michelle
Top achievements
Rank 1
Share this question
or