I've seen in several sites where publish some images of their applications using a style for ErrorTemplate like this:
Do you know where can I find it?
I've seen in several sites where publish some images of their applications using a style for ErrorTemplate like this:
Do you know where can I find it?
I just whipped one up, took a little tinkering but it works in my WPF test application (using .Net 4.0). I actually wanted something like this for an application I'm working on, so your question was a convenient excuse to make one. =)
This code uses the Validation.ErrorTemplate
attached property to create an ControlTemplate
that sets up a red border to outline the validated control, and then a Popup
that contains the error message for the control. I had to get the error message from the validated control's ToolTip
property because the TextBox
inside the template didn't seem to have access to the Validation
class itself.
The popup error message closes when the validated control looses focus, and reappears (if there is an error) when it gains focus again.
Here's a screenshot:
Here's the gist code: https://gist.github.com/1672789
I'm open to any comments or improvements anyone would offer.
This looks much like Adorner. The idea is to draw something above/near the control where its defined which is not also affected by transformations applied to scene.
For example you can define a Adorner in
Style
of yourTextBox
.Something like this (a pseudocode):
A complete example (for
ScrollViewer
, but the ides is the same) can find here