Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The ErrorTemplate is an <a href="http://msdn.microsoft.com/en-us/library/ms743737.aspx" rel="noreferrer">adorner</a>, not a replacement for the control template. You include an <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.adornedelementplaceholder.aspx" rel="noreferrer"><code>AdornedElementPlaceholder</code></a> in the template where you want to leave space for the original control. So, your error template should look like: </p> <pre><code>&lt;Setter Property="Validation.ErrorTemplate"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate&gt; &lt;Grid Name="test"&gt; &lt;AdornedElementPlaceholder/&gt; &lt;Image Name="ErrorImage" Width="24" Height="24" Margin="0,0,4,0" Source="/Images/error.png" HorizontalAlignment="Right"/&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; </code></pre> <p>Since you also want to change the color of the border, I would use a TemplateBinding for the border brush and change that in the Validation.HasError trigger: </p> <pre><code>&lt;Setter Property="BorderBrush" Value="{StaticResource BorderColor}"/&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type TextBox}"&gt; &lt;Border Background="{StaticResource TextBackColor}" BorderBrush="{TemplateBinding BorderBrush}" x:Name="Bd" CornerRadius="4" BorderThickness="2"&gt; &lt;ScrollViewer Margin="0" x:Name="PART_ContentHost"/&gt; &lt;/Border&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Style.Triggers&gt; &lt;Trigger Property="Validation.HasError" Value="True"&gt; &lt;Setter Property="BorderBrush" Value="#d99"/&gt; &lt;/Trigger&gt; &lt;/Style.Triggers&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload