How can I force validation when user clicks button?
One would think this should be easy, since always you have to do something if the element values are valid.
private void buttonOk_Click(object sender, RoutedEventArgs e)
{
// How can I force the validation here? So that empty values are not allowed (validator doesn't allow those)
if (Validation.GetHasError(textBoxURI) ||
Validation.GetHasError(textBoxName)) // These return valid values if user has not changed values in fields.
return;
DialogResult = true;
this.Close();
}
As you can guess, the empty value is invalid according to my validator (if I type something to textbox) then empty it and blur the focus it will show invalid value.
As a side note: UpdateSourceTrigger
won't affect the related problem that initial values are not validated.