title: RelayCommand Params & Binding
body: <p><strong>View:</strong></p>
  
  <p>Playing with a basic calculator using WPF(MVVM).
  I've 1 TextBox for the first num, 1 TextBox for the second num, 1 TextBlock for the results and 1 Button to execute the AddCommand and return the result.
  What's the right XAML syntax to bind these controls to the right Data.</p>
  
  <p><strong>Model:</strong></p>
  
  <pre><code>public class Operation : INotifyPropertyChanged
  {
      private double _result;
      public Operation()
      {
          _result = 0;
      }
  
      public double Result
      {
          get { return _result; }
          set
          {
              if (value != _result)
              {
                  _result = value;
                  RaisePropertyChanged("Result");
              }
          }
      }
  
      public double DoAdd(double first, double second)
      {
          _result = first + second;
          return _result;
      }
  }
  </code></pre>
  
  <p><strong>ViewModel:</strong></p>
  
  <pre><code>public class CalcViewModel
  {
      private Operation _operation;
      public RelayCommand AddCommand { get; set; }
  
      public CalcViewModel()
      {
          _operation = new Operation();
  
          // This is not correct, how to define the AddCommand here so it takes two params
          // The first and second nums to work with.
          AddCommand = new RelayCommand(first, second =&gt; ExecuteAddCommand(first, second));
      }
  
      private void ExecuteAddCommand(double first, double second)
      {
  
          // How to bind this returned double to the TextBlock in View
          _oepration.DoAdd(first, second);
      }
  }
  </code></pre>
  
  <p><strong>EDIT new version of code on request of Vlad</strong></p>
  
  <p><strong>Model:</strong></p>
  
  <pre><code>public class Operation
      {
          private double _result;
  
          public Operation()
          {
              _result = 0;
          }
  
          public double Result
          {
              get { return _result; }
          }
  
          public void PerformAdd(double leftNum, double rightNum)
          {
              _result = leftNum + rightNum;
          }
      }
  </code></pre>
  
  <p><strong>ViewModel:</strong></p>
  
  <pre><code> public class CalcViewModel
      {
          private Operation _operation;
          public double LeftNumber { get; set; }
          public double RightNumber { get; set; }
          public double Result { get; set; }
  
          public RelayCommand AddCommand { get; set; }
  
          public CalcViewModel()
          {
              AddCommand = new RelayCommand(a =&gt; ExecuteAddCommand());
              _operation = new Operation();
          }
  
          private void ExecuteAddCommand()
          {
              _operation.PerformAdd(LeftNumber, RightNumber);
              Result = _operation.Result;
          }
  </code></pre>
  
  <p><strong>View XAML:</strong></p>
  
  <pre><code>&lt;TextBox Text="{Binding LeftNumber}" /&gt;
  &lt;TextBox Text="{Binding RightNumber}" /&gt;
  &lt;TextBox Text="{Binding Result}" /&gt;
  &lt;Button Content="Add" Command="{Binding AddCommand}" /&gt;
  </code></pre>
  
  <p><strong>View Code behind:</strong></p>
  
  <pre><code>public partial class CalcUserControl : UserControl
  {
      CalcViewModel vm;
  
      public CalcUserControl()
      {
          InitializeComponent();
          vm = new CalcViewModel();
          this.DataContext = vm;
      }
  }
  </code></pre>
  
  <p>I tried all modes of binding without any result. I have here an additional question, what's the default binding mode in such a situation?</p>
  
  <p>I even thought that it has to do with the datatype of the calculation, so I swiched from double to int, but still not working.</p>