private void OKClicked(object sender, RoutedEventArgs e) { List <string> errors = new List <string>(); ISet <ValidationError> validationErrors = WindowsUtility.GetValidationErrors(this.grid); foreach (ValidationError error in validationErrors) { errors.Add(error.ErrorContent?.ToString() ?? "Validation error"); } if (errors.Count == 0) { this.DialogResult = true; } else { WindowsUtility.ShowError(this, string.Join("\n", errors)); } }