Created
March 8, 2011 23:43
-
-
Save PaulStovell/861384 to your computer and use it in GitHub Desktop.
This is how you can disable paste in TextBoxes in WPF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <Window x:Class="WpfApplication9.MainWindow" | |
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
| Title="MainWindow" Height="350" Width="525"> | |
| <Grid> | |
| <TextBox Name="MyTextBox" Text="Hello" /> | |
| </Grid> | |
| </Window> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public MainWindow() | |
| { | |
| InitializeComponent(); | |
| MyTextBox.CommandBindings.Add(new CommandBinding(ApplicationCommands.Paste, Foo)); | |
| } | |
| private void Foo(object sender, ExecutedRoutedEventArgs e) | |
| { | |
| e.Handled = true; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment