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

Disable context menu

1 Answer 43 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Donna Rich
Top achievements
Rank 1
Donna Rich asked on 22 Feb 2010, 03:03 PM
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?

1 Answer, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 23 Feb 2010, 03:57 PM
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.
Tags
TreeView
Asked by
Donna Rich
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Share this question
or