Tuesday, 13 August 2019

Barrah


BARAH

In C#, Validation class needs to be added in the code that allow to to handle the error by registering an error handler.

Validation.AddErrorHandler(textBoxName, textBox_ValidationError); this method is called within MainWindow()

protected void textBox_ValidationError(object sender, ValidationErrorEventArgs error){
MessageBox.Show(string)error.Error.ErroContent);
}

When an error occurred, the messageBox will show from textBox_ValidationError method and it will notify the user.

In XAML, the error handling is done using Notification window, when an error occurred error notification window will show on the scree.

<TextBox.Text>
<Binding Path = "FieldName"
NotifyValidationError = "True">
</Binding>
</TextBox.Text>

Above, when the data input is invalid, error will be notified.

No comments:

Post a Comment