WPF禁用文本框的copy,paste,cut功能
2015-12-30 17:29
323 查看
禁用文本框的copy,paste,cut 菜单,以及对应的快捷键
一个简单的例子
Xaml
<TextBox Height="23" HorizontalAlignment="Left" Name="textBox1" VerticalAlignment="Top" Width="120" BorderBrush="#FF444444" Foreground="#FF3C4661" FontSize="13"
InputMethod.IsInputMethodEnabled="False"
Text="Hello"
ContextMenu="{x:Null}">
<TextBox.CommandBindings>
<CommandBinding Command="ApplicationCommands.Paste" CanExecute="CommandBinding_CanExecute"></CommandBinding>
<CommandBinding Command="ApplicationCommands.Cut" CanExecute="CommandBinding_CanExecute"></CommandBinding>
<CommandBinding Command="ApplicationCommands.Copy" CanExecute="CommandBinding_CanExecute"></CommandBinding>
</TextBox.CommandBindings>
</TextBox>
------------------------------------------
Xaml.cs
private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = false;
e.Handled = true;
}
一个简单的例子
Xaml
<TextBox Height="23" HorizontalAlignment="Left" Name="textBox1" VerticalAlignment="Top" Width="120" BorderBrush="#FF444444" Foreground="#FF3C4661" FontSize="13"
InputMethod.IsInputMethodEnabled="False"
Text="Hello"
ContextMenu="{x:Null}">
<TextBox.CommandBindings>
<CommandBinding Command="ApplicationCommands.Paste" CanExecute="CommandBinding_CanExecute"></CommandBinding>
<CommandBinding Command="ApplicationCommands.Cut" CanExecute="CommandBinding_CanExecute"></CommandBinding>
<CommandBinding Command="ApplicationCommands.Copy" CanExecute="CommandBinding_CanExecute"></CommandBinding>
</TextBox.CommandBindings>
</TextBox>
------------------------------------------
Xaml.cs
private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = false;
e.Handled = true;
}
相关文章推荐
- Win7 x64系统下PHP开发环境搭建(Apache2.4.18+PHP5.6.16+MySQL5.7.10+phpMyAdmin4.5.3.1)
- jq中 offset()方法, scrollTop()方法以及scrollLeft()方法
- 【原创】linux学习笔记之文件处理命令
- linux下创建expdp备份的计划任务
- Android图片缓存架构
- Linux下安装mysql
- Linux mysql 数据库自动备份
- Linux查询网址
- Linux文件与目录常用命令
- Tomcat启动找不到maven里的类 抛ClassNotFoundException
- 运维安全系列基础服务之 FTP 服务(系列一)
- nginx upstream timed out (110: Connection timed out) while reading response header from upstream
- linux使用xinetd自定义服务
- 让tomcat显示目录文件列表的配置方法
- Install OpenCV 2 on Mac OSX
- Linux环境下安装部署AWStats日志分析系统实例
- Linux(Ubuntu)下MySQL的安装与配置
- Linux的文件权限与目录配置
- CheungSSH web2.0 自动化运维
- Linux下很全面的监控工具dstat