We use the standard method for our controls to report a violation of the BO rules. This is done through the IDataError interface in our BOs, and in XAML the control is bound to the BOs property, etc. This approach works fine. But we need to show 2 types of visual elements in the user interface depending on the type (or category, if you like) of the invalidation error. If this is a required field, we display a CueBanner (water sign), but for other types we change the color of the control panel. In both scenarios, we set the type of error message tool.
The problem with IDataError is that it does not support a method / property to distinguish between types of errors.
The only way I can do this is to check the error text, the required field text should contain the keyword “required”. The following approach does not feel right, but the only way to determine the type of error, and then handle it accordingly. All required field rules must have a "required field" as part of the error text. To do all this, I created my own dependency property called ErrorMessage. In my ResourceDictionary, I have a Style.Trigger for Validation.HasError. There I set the value of the dependency properties to ErrorContent. Now that the values of the dependency properties change, I can examine the text and set the Validation.SetErrorTemplate (myControl, newErrorTemplate) template to the template according to the type of error.I need to connect several events to the management, for example, to lose and gain focus in order to control the removal or addition of the cueBanner template, but it will all work. Simply, I'm not sure if this is the best way to do this.
PS. ErrorTemplate im, , . Validation.SetErrorTemplate , , ?
, .
McKay