title: How to pass 2 PasswordBoxes as CommandParameter to Command?
body: <p>In WPF, PasswordBox.Password is not a DP, so we can't directly bingding it in ViewModel. I have done an online search, use this methods, but the converter just is called one time when the view is loaded, so the parameter in ExecuteMyCommand is null:</p>
  
  <p>MainWindow.xaml
      </p>
  
  <pre><code>    &lt;DockPanel x:Name="WindowLayout" LastChildFill="False"&gt;
          &lt;Grid DockPanel.Dock="Top" Margin="10"&gt;
              &lt;Grid.RowDefinitions&gt;
                  &lt;RowDefinition Height="Auto" /&gt;
                  &lt;RowDefinition Height="Auto" /&gt;
              &lt;/Grid.RowDefinitions&gt;
              &lt;Grid.ColumnDefinitions&gt;
                  &lt;ColumnDefinition Width="Auto" /&gt;
                  &lt;ColumnDefinition /&gt;
              &lt;/Grid.ColumnDefinitions&gt;
              &lt;TextBlock Text="PasswordBox1" VerticalAlignment="Center"/&gt;
              &lt;PasswordBox x:Name="PswBox" Grid.Column="1" Height="27"/&gt;
              &lt;TextBlock Text="PasswordBox2" VerticalAlignment="Center" Grid.Row="1"/&gt;
              &lt;PasswordBox x:Name="AgainPswBox" Grid.Column="1" Grid.Row="1" Height="27"/&gt;
          &lt;/Grid&gt;
  
          &lt;Button IsDefault="True" Command="{Binding MyCommand}" DockPanel.Dock="Top" Content="Click" Width="60" Margin="10"&gt;
              &lt;Button.CommandParameter&gt;
                  &lt;MultiBinding Converter="{cvt:PlainMultiValueConverter}"&gt;
                      &lt;Binding ElementName="PswBox"/&gt;
                      &lt;Binding ElementName="AgainPswBox"/&gt;
                  &lt;/MultiBinding&gt;
              &lt;/Button.CommandParameter&gt;
          &lt;/Button&gt;
      &lt;/DockPanel&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>Converters\PlainMultiValueConverter.cs</p>
  
  <pre><code>namespace MVVM_Light_Base.Converters
  {
      [MarkupExtensionReturnType(typeof(PlainMultiValueConverter))]
      //[ValueConversion(typeof(object[]), typeof(object))]
      public class PlainMultiValueConverter : MarkupExtension,
          IMultiValueConverter
      {
          public static PlainMultiValueConverter converter = null;
  
          public override object ProvideValue(IServiceProvider serviceProvider)
          {
              if (null == converter)
              {
                  converter = new PlainMultiValueConverter();
              }
              return converter;
          }
  
          public object Convert(object[] values, Type targetType,
              object parameter, System.Globalization.CultureInfo culture)
          {
              return values;
          }
  
          public object[] ConvertBack(object value, Type[] targetTypes,
              object parameter, System.Globalization.CultureInfo culture)
          {
              throw new NotImplementedException();
          }
      }
  }
  </code></pre>
  
  <p>ViewModel\MainViewModel.cs</p>
  
  <pre><code>using GalaSoft.MvvmLight;
  using GalaSoft.MvvmLight.Command;
  using System.Windows.Controls;
  namespace MVVM_Light_Base.ViewModel
  {
      public class MainViewModel : ViewModelBase
      {
          private RelayCommand&lt;object&gt; myCommand;
  
          public RelayCommand&lt;object&gt; MyCommand
          {
              get
              {
                  return myCommand ?? (myCommand =
                      new RelayCommand&lt;object&gt;(ExecuteMyCommand));
              }
          }
  
          private void ExecuteMyCommand(object parameter)
          {
              var pswBoxes = parameter as object[];
              PasswordBox pb;
              string psw0;
              string psw1;
  
              try
              {
                  pb = pswBoxes[0] as PasswordBox;
                  psw0 = pb.Password;
                  pb = pswBoxes[1] as PasswordBox;
                  psw1 = pb.Password;
              }
              catch
              {
                  return;
              }
          }
      }
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/HOZgD.png" alt="enter image description here"></p>
  
  <p>Why the converter didn't work perfectly? And how should I do?</p>