本文介绍了多个命令参数的WPF按钮对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何发送从按钮
多个参数的 WPF
?我能够发送单一的参数是文本框的值
正常。这里是code。
XAML
<文本框Grid.Row =1HEIGHT =23的HorizontalAlignment =左保证金=133,22,0,0NAME =textBox1的VerticalAlignment = 顶级WIDTH =120/>
<按钮内容=按钮Grid.Row =1HEIGHT =23命令={绑定路径= CommandClick}CommandParameter ={结合文本,的ElementName = textBox1的}的HorizontalAlignment =左保证金= 133,62,0,0NAME =Button1的VerticalAlignment =评出的WIDTH =75/>
code后面
公共ICommand的CommandClick {搞定;组; }this.CommandClick =新DelegateCommand<对象>(AddAccount);私人无效AddAccount(obj对象)
{
//自定义逻辑
}
解决方案
You can only send one parameter as the CommandParameter
.
A better solution is typically to just bind the TextBox
and other controls to multiple properties in your ViewModel. The command would then have access to all of those properties (since it's in the same class), with no need for a command parameter at all.
这篇关于多个命令参数的WPF按钮对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!