private void ValidateRequiredFields(TextBox txtUsername, PasswordBox txtPassword, TextBox txtFirstName, TextBox txtLastName, out bool Validated) { Validated = false; if(txtUsername.Text.IsNullOrEmpty()){ txtUsername.FlagAsError(); return; } txtUsername.FlagAsCorrect(); if (txtPassword.Password.IsNullOrEmpty()) { txtPassword.FlagAsError(); return; } txtPassword.FlagAsCorrect(); if (txtFirstName.Text.IsNullOrEmpty()) { txtFirstName.FlagAsError(); return; } txtFirstName.FlagAsCorrect(); if (txtLastName.Text.IsNullOrEmpty()) { txtLastName.FlagAsError(); return; } txtLastName.FlagAsCorrect(); Validated = true; }