In this article we will see how we can restrict Clipboard shortcuts such as CTRL+C, CTRL+X, and CTRL+V in Silverlight 3 for TextBox Control.
IntroductionIn this article we will see how we can restrict Clipboard shortcuts such as CTRL+C, CTRL+X, and CTRL+V in Silverlight 3 for TextBox Control.Creating Silverlight ProjectFire up Visual Studio 2008 and create a new Silverlight 3 Project. Name it as RestrictCBShortcutSL3. Let's have one or more TextBoxes that will fulfill our sample application. Now for disabling Clipboard shortcuts such as Ctrl+C, Ctrl+X, and Ctrl+V we need to have Custom TextBox control.So Create a class as CustomTextBox.cs . Now inherit TextBox class to it. Now we will have a boolean property that will decide whether CTRL key is pressed. To override default shortcuts we need to override the base methods such as OnKeyDown and OnkeyUp.Add the following override methods. Now go back to the XAML code behind and add the Namespace (Your application's namespace) as follows: After adding the Namespace Change the TextBox Control that you need to restrict the Clipboard shortcuts. In our case we will do it for the About User TextBox. Initialize the IsControlKeyDown property to False. Now we are ready to test our application. Try pressing Ctrl+C/Ctrl+X/Ctrl+V the clipboard shortcuts are handled.Hope this article helps.
Printing in C# Made Easy