Multiple command parameters wpf button object

button, c#, icommand, mvvm, wpf

Solution

How can i send multiple parameters from button in wpf.

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.

Problem

How can I send multiple parameters from `Button` in `WPF`? I am able to send single parameter which is value of `TextBox` properly. Here is the code. `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 } ```

Original source