title: Should I move the code from code behind file to ViewModel
body: <p>I have buttons and slider in the window. Also I have a button click event. The thing is I use the click event in code behind. However I also adopt MVVW pattern. So I guess that I may convert the code with <code>ICommand</code> etc. I am not sure if it is a right decision.</p>
  
  <p><strong>Please look at my code and advise me.</strong> I am new to <code>ICommand</code> and <code>CanExecute</code>.</p>
  
  <pre><code>MainViewModel _dataContext;
  public MainWindow()
  {
      InitializeComponent();
      _dataContext = new MainViewModel();
      this.DataContext = _dataContext;
      _dataContext.ServerString = "  Connected to Server " +  ConfigurationManager.AppSettings["Server"]";
  }
  
  private async void buttonStart_Click(object sender, RoutedEventArgs e)
  {
      try
      {
          cTokenSource = new buttonCancellationTokenSource();
          cToken = cTokenSource.Token;
          paymentTestNumber = count;
          buttonStart.IsEnabled = false;
          buttonStart.IsHitTestVisible = false;
          buttonStart.Background = Brushes.Red;
          buttonCancel.IsEnabled = true;
          buttonCancel.Background = Brushes.Green;
          buttonCancel.IsHitTestVisible = true;
  
          _dataContext.Items.Clear();
          _dataContext.PaymentTotal = PaymentTotal;
          _dataContext.TotalSuccess = string.Empty;
          _dataContext.TotalFail = string.Empty;
          m_Queue = new BufferBlock&lt;AppointmentReminder&gt;(new DataflowBlockOptions { BoundedCapacity = 1000 }); // bufferBlock
          slider.IsEnabled = false;
          var producer = Producer(paymentTestNumber);
          var consumer = Consumer();
  
          await Task.WhenAll(producer, consumer);
          Summary();
          slider.IsEnabled = true;
          cTokenSource = null;
      }
  </code></pre>
  
  <p>For the <strong>View Model</strong>.</p>
  
  <pre><code>public class MainViewModel : NotifyUIBase
  {
      private string serverString;
      public string ServerString
      {
          get { return serverString; }
          set
          {
              serverString = value;
              RaisePropertyChanged();
          }
      }
  
      public ObservableCollection&lt;Calls&gt; items = new ObservableCollection&lt;Calls&gt;();
      public ObservableCollection&lt;Calls&gt; Items
      {
          get { return items; }
          set
          {
              items = value;
              RaisePropertyChanged();
          }
      }
  </code></pre>
  
  <p>It works well but it may be against the MVVM priciple.
  So my question is: Do I need convert the event <code>buttonStart_Click</code> to <code>ICommand</code> etc.?</p>