在WPF中创建文本框事件? [英] Create a textbox event in WPF?
本文介绍了在WPF中创建文本框事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的窗口中有一个文本框,有人可以在其中输入内容,然后当他们按Enter键时,它会在屏幕上生成某些内容,例如,其中包含该文本的小框.是否可以为文本框创建事件或命令,并将该文本框的text属性绑定到其生成的内容?
谢谢.
I want to have a textbox in my window where someone can type something into it and when they hit enter, it generates something on the screen, say, a small box with that text in it. Is it possible to create and event or command for a textbox and have that textbox''s text property bound to what it generates?
Thanks.
推荐答案
你好,
您可以使用以下提示以更简单的方式完成此操作: ^ ]
:)
Hello,
You could have done it a simplier way by using this tips : http://blog.lexique-du-net.com/index.php?post/2010/02/17/Use-AttachedProperties-to-add-behaviors-to-the-component[^]
:)
我想您是在谈论双向绑定.
参见此处.
I guess you are talking about two-way binding.
See here.
我通过创建自己的TextBox类(称为CommandTextBox)解决了这个问题,该类注册了3个依赖项属性:command,commandParameter和commandTarget.
我使用此网站寻求帮助: http://msdn.microsoft.com /en-us/library/system.windows.input.icommandsource.commandparameter.aspx [
I solved this problem by creating my own TextBox class, called CommandTextBox which registers 3 Dependency properties: command, commandParameter, and commandTarget.
I used this site for help: http://msdn.microsoft.com/en-us/library/system.windows.input.icommandsource.commandparameter.aspx[^]
这篇关于在WPF中创建文本框事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文