TextBox子类中的预定义命令 [英] Predefined commands in TextBox subclass

查看:80
本文介绍了TextBox子类中的预定义命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ComponentCommands.MoveFocusUp具有默认的按键手势(Ctrl + Up),我想在派生自TextBox的自定义类中使用它.
我将TextBox子类化,并添加了以下命令绑定:

ComponentCommands.MoveFocusUp has a default key gesture (Ctrl+Up) I''d like to use in a custom class derived from TextBox.
I''ve subclassed TextBox, added following command bindings:

this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, CopyCommandHandler)); // Ctrl+C
this.CommandBindings.Add(new CommandBinding(ComponentCommands.MoveFocusUp, MoveCurrentLineUpCommandHandler)); // Ctrl+Up


到默认的构造函数,也定义了处理程序.但是,只有CopyCommandHandler响应键盘交互.有任何建议吗?


to the default constructor, and defined handlers too. But only CopyCommandHandler responds to keyboard interaction. Any suggestions?

推荐答案

此解决方案对我有用:
http://www.switchonthecode.com/tutorials/wpf-tutorial-command-绑定和自定义命令 [ ^ ]
This solution worked for me:
http://www.switchonthecode.com/tutorials/wpf-tutorial-command-bindings-and-custom-commands[^]


这篇关于TextBox子类中的预定义命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆