Archives for the 'Silverlight' Category

Implementing the right-click context menu in Silverlight 4

Download and install Silverlight 4 Toolkit - April 2010.
In your Silverlight 4 project, add references to:

System.Windows.Controls
System.Windows.Controls.Input.Toolkit

In your UserControl XAML, add the following to the LayoutRoot grid opening tag: MouseRightButtonDown=”LayoutRoot_MouseRightButtonDown” MouseRightButtonUp=”LayoutRoot_MouseRightButtonUp”
In the codebehind:

using System.Windows.Controls;

private void LayoutRoot_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
e.Handled = true;
}

private void LayoutRoot_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
var contextMenu = […]

16 November 2010 | Silverlight, .NET | 2 Comments