Disable context menu

2 posts, 0 answers
  1. Donna Rich
    Donna Rich avatar
    1 posts
    Member since:
    Jan 2010

    Posted 22 Feb 2010 Link to this post

    I have a context menu that pops up when you right-click in IE.  Do you know how right-click can be disabled in Silverlight, such that the context menu that I have created won't display?
  2. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 23 Feb 2010 Link to this post

    Hello Donna Rich,

    I am not sure that I understand your scenario clearly but I can answer your question:

    The right click in Silverlight can be disabled by handling one of the Telerik routed events:

    using System;
    using System.Windows.Controls;
    using Telerik.Windows.Input;
      
    namespace RightClickDisable
    {
        public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
      
                Mouse.AddMouseUpHandler(this, new EventHandler<MouseButtonEventArgs>(OnMouseUp));
            }
      
            private void OnMouseUp(object sender, MouseButtonEventArgs e)
            {
                if (e.ChangedButton == MouseButton.Right)
                {
                    e.Handled = true;
                }
            }
        }
    }

    Please note that your Silverlight application needs to be windowless.

    The example above is attached to my reply.

    Greetings,
    Miroslav
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top