Search code examples
c#wpfvalidationidataerrorinfo

How to create a similar template like this for errors?


I've seen in several sites where publish some images of their applications using a style for ErrorTemplate like this:

enter image description here

Do you know where can I find it?


Solution

  • 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 your TextBox.

    Something like this (a pseudocode):

    <Style TargetType="{x:Type TextBox}">
         <Setter Property="Template">
                    <Setter.Value>
                       <ControlTemplate TargetType="{x:Type ScrollViewer}">
                           ........
                           ........
                           <AdornerDecorator Grid.Column="0" Grid.Row="0">
                               .........
                               .........
                           </AdorenrDecorator>
                        </ControlTemplate>
                    </Setter.Value>
         </Setter>
    </Style>
    

    A complete example (for ScrollViewer, but the ides is the same) can find here