Web
How to add a right click context menu on a TextBox in Silverlight and also support simple editing commands, like Cut, Copy and Paste? This is pretty easy with RadContextMenu for Silverlight and I will show you now: First I declared a TextBox and set the RadContextMenu.ContextMenu attached property on it: <TextBox x:Name="TextContainer" AcceptsReturn="True" TextWrapping="Wrap" Text="Right click to open a fully functional context menu that depends on the selection and the clipboard content"> <telerikNavigation:RadContextMenu.ContextMenu> <telerikNavigation:RadContextMenu ItemClick="ContextMenuClick" Opened="ContextMenuOpened" Closed="ContextMenuClosed"> <telerikNavigation:RadMenuItem Header="Cut" /> <telerikNavigation:RadMenuItem Header="Copy" /> <telerikNavigation:RadMenuItem Header="Paste" /> </telerikNavigation:RadContextMenu> </telerikNavigation:RadContextMenu.ContextMenu> </TextBox>
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
If you want to open the context menu with Right click, you need to make the Silverlight plug-in windowless. Otherwise, you should set the EventName and/or ModifierKey properties on RadContextMenu to configure it...