title: How to use the CommandParameter in XAML
body: <p>I am a little lost in how to use the CommandParameter in XAML. I am trying to bind a TextBox and a Button. </p>
  
  <p><strong>This my XAML code:</strong></p>
  
  <pre><code>&lt;TextBox x:Name="txtCity" Height="70"
           VerticalAlignment="Top"/&gt;
  &lt;Button x:Name="btnCity"
          Content="Get"
          Background="CornflowerBlue"
          Height="70"
          Command="{Binding GetweatherCommand}"
          CommandParameter="{Binding ElementName=txtCity, Path=Text}"/&gt;
  </code></pre>
  
  <p><strong>In my ViewModel class</strong> I have the following to handle the clic action:</p>
  
  <pre><code>ActionCommand getWeatherCommand;          //ActionCommand derivides from ICommand
  public ActionCommand GetWeatherCommand
  {
          get
          {
              if (getClimaCommand != null)
              {
                  getClimaCommand = new ActionCommand(() =&gt;
                      {
                          serviceModel.getClima("????");
                      });
              }
  
              return getWeatherCommand;
          }
   }
  </code></pre>
  
  <p><strong>My ActionCommand class:</strong></p>
  
  <pre><code>public class ActionCommand : ICommand
  {
      Action action;
      public ActionCommand(Action action)
      {
          this.action = action;
      }
  
      public bool CanExecute(object parameter)
      {
          return true;
      }
  
      public event EventHandler CanExecuteChanged;
  
      public void Execute(object parameter)
      {
          action();
      }
  }
  </code></pre>
  
  <p>When I debug, the parameters in the <code>Execute</code> and <code>CanExecute</code> methods have the proper value.  However, I guess the problem is in the method from the <code>ViewClass (GetWeatherCommand)</code>.  I can't figure out how to pass the parameter.</p>
  
  <p>So, based on the above, does anyone know how can I pass the parameter to the method that will be executed? </p>