I have a TextBox in my WPF app. I have defined a ControlTemplate for validation error as follows:
Thanks to for the wonderful link he suggested me.My code goes somewhat this way
String errorMessage = GetFormattedErrorMessage(toolTip.Range, range);
ValidationError validationError = new ValidationError(new DummyValidator(),
txtBox.GetBindingExpression(TextBox.TextProperty));
Validation.MarkInvalid(txtBox.GetBindingExpression(TextBox.TextProperty), validationError);
validationError.ErrorContent = errorMessage;
Validation.SetErrorTemplate(txtBox, GetErrorTemplate(errorMessage));