I have a TextBox in my WPF app. I have defined a ControlTemplate for validation error as follows:
For your first question. You can set the ErrorTemplate from code behind like.
public MainWindow()
{
InitializeComponent();
var template = this.FindResource("validationTemplate") as ControlTemplate;
Validation.SetErrorTemplate(this.textBox1, template);
}
Edit:
For your second question. Please refer the following sample.
sites.google.com/site/html5tutorials/ValidationErrorText.zip