如何從Button
在WPF
發送多個參數?我能夠正確地發送值爲TextBox
的單個參數。這是代碼。多個命令參數wpf按鈕對象
XAML
<TextBox Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="133,22,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" />
<Button Content="Button" Grid.Row="1" Height="23" Command="{Binding Path=CommandClick}" CommandParameter="{Binding Text,ElementName=textBox1}" HorizontalAlignment="Left" Margin="133,62,0,0" Name="button1" VerticalAlignment="Top" Width="75" />
Code behind
public ICommand CommandClick { get; set; }
this.CommandClick = new DelegateCommand<object>(AddAccount);
private void AddAccount(object obj)
{
//custom logic
}
如果您描述了您想要的確切參數,它們的類型以及原因,我們可能會提供幫助。命令參數只有一個「綁定」,但根據您的需要還有其他選項,請更多信息。 – 2013-04-11 15:30:25
例如,您可以使用對象[](對象數組)對一個參數進行多個參數轉換,但您需要將所有這些參數向後轉換。或者有問題嗎? – Master117 2013-04-11 15:38:48
嗨J國王,它會另一個控制。一個文本框可以是很好的假設。 – 2013-04-11 16:19:24