Disable RadDock ContextMenu animation

3 posts, 1 answers
  1. Michelle
    Michelle avatar
    13 posts
    Member since:
    Nov 2010

    Posted 20 Jun 2013 Link to this post

    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. Answer
    Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 25 Jun 2013 Link to this post

    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?
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Michelle
    Michelle avatar
    13 posts
    Member since:
    Nov 2010

    Posted 27 Jun 2013 Link to this post

    That is fantastic -- works like a charm! Thank you so much for the great support and plug 'n play code.


    Michelle
Back to Top