title: Execute Two RelayCommands On One Button Press - WPF
body: <p>I have a button that allows the user to register an account. When the user presses the button I have a relay command execute a method that submits their details to the database. If successful, I then want the user to be transferred to the login screen.</p>
  
  <p>I have used EnumStateVisibility, when I used a converter that triggers UserControls visible or hidden.</p>
  
  <p><strong>Here is the code that I have:</strong></p>
  
  <p><strong>Submit account details to database on press</strong></p>
  
  <p><a href="https://i.stack.imgur.com/cSdcF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cSdcF.jpg" alt="Submit account details button"></a></p>
  
  <pre><code>/// &lt;summary&gt;
          /// Submits users details to database and checks criteria
          /// &lt;/summary&gt;
          public RelayCommand SubmitRegisterAccountDetails
          {
              get
              {
                  SubmitAccountDetails submit = new SubmitAccountDetails();
                  return new RelayCommand(param =&gt; submit.SubmitLoginUserDetails(EmailAddress, Mail, Password, CurrentState));
              }
          }
  
  
  
  
  // Enum State to visibility converter, toggles login and register views on and off in window
      public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
              {
                  LoginVisibilityStates state = (LoginVisibilityStates)value;
                  LoginVisibilityStates para = (LoginVisibilityStates)Enum.Parse(typeof(LoginVisibilityStates), parameter.ToString());
  
                  if (state == para)
                      return Visibility.Visible;
                  else
                      return Visibility.Hidden;
              }
  
              public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
              {
                  throw new NotImplementedException();
              }
  
  
  
  // Logic to switch UserControl when user presses a different button, with
  // this relaycommand set as the command and "Login" or "Register" as the CommandParameter
  
      private LoginVisibilityStates _currentState;
          public LoginVisibilityStates CurrentState
          {
              get
              {
                  return _currentState;
              }
              set
              {
                  _currentState = value;
                  OnPropertyChanged("CurrentState");
              }
          }
  
          #region Commands
          public RelayCommand SwitchCommand
          {
              get
              {
                  return new RelayCommand(ChangeState);
              }
          }
          #endregion
  
          public void ChangeState(object parameter)
          {
              switch (parameter.ToString())
              {
                  case "Register":
                      CurrentState = LoginVisibilityStates.Register;
                      break;
                  case "Login":
                      CurrentState = LoginVisibilityStates.Login;
                      break;
                  default:
                      break;
              }
          }
  </code></pre>