Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing a Control Template for all controls across the application
    text
    copied!<p>I have a control template in one of my pages and i am assigning this template to my textbox's Validation.ErrorTemplate property. The following code would give you a better view.</p> <pre>&lt;ControlTemplate x:Key="ValidationErrorTemplate"&gt; &lt;StackPanel Orientation="Horizontal" HorizontalAlignment="Right"&gt; &lt;AdornedElementPlaceholder/&gt; &lt;Image Name="ValidizorImage" Stretch="None" Source="validizor.gif" ToolTip="{Binding [0].ErrorContent}" ToolTipService.InitialShowDelay="0" ToolTipService.ShowDuration="60000"/&gt; &lt;/StackPanel&gt; &lt;/ControlTemplate&gt;</pre> <p>The above template sets the image at the end of the textbox which is having the error. This template is used as below.</p> <pre>&lt;TextBox Grid.Column="5" Grid.Row="1" x:Name="txtemail" Grid.ColumnSpan="3" Margin="0,1,20,1" Validation.ErrorTemplate="{StaticResource ValidationErrorTemplate}" /&gt;</pre> <p>My question here is</p> <p>I want to move this control template outside of this page so that i can use it across the application. </p> <p>I tried putting the exact same code of the control template in a user control say "ErrorUC" </p> <pre> &lt;UserControl...&gt; &lt;Grid&gt; &lt;StackPanel Orientation="Horizontal" HorizontalAlignment="Right"&gt; &lt;AdornedElementPlaceholder/&gt; &lt;Image Name="ValidizorImage" Stretch="None" Source="validizor.gif" ToolTip="{Binding [0].ErrorContent}" ToolTipService.InitialShowDelay="0" ToolTipService.ShowDuration="60000"/&gt; &lt;/StackPanel&gt; &lt;/Grid&gt; &lt;/UserControl&gt; </pre> <p>and used it as below</p> <pre>TextBox1.SetResourceReference (System.Windows.Controls.Validation.ErrorTemplateProperty, new ErrorUC());</pre> <p>On running the above code i learnt that "AdornedElementPlaceholder" can be used only in templates and not in user controls. If i comment the same i am not getting the desired result.</p>
 

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