Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9011763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:49:23+00:00 2026-06-16T02:49:23+00:00

I have a template written in xaml. Can you write how a template is

  • 0

I have a template written in xaml. Can you write how a template is turned on for TextBox?

        <Grid.Resources>
        <Storyboard x:Key="FlashErrorIcon">
        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00"                                        Storyboard.TargetProperty="(UIElement.Visibility)">
                <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Hidden}"/>                                 
                <DiscreteObjectKeyFrame KeyTime="00:00:03.2000000" Value="{x:Static Visibility.Visible}"/>
                <DiscreteObjectKeyFrame KeyTime="00:00:01" Value="{x:Static Visibility.Visible}"/>
            </ObjectAnimationUsingKeyFrames>
        </Storyboard>
        <Style TargetType="{x:Type TextBox}">
            <Style.Triggers>
                <Trigger Property="Validation.HasError" Value="true">
                    <Setter Property="Background" Value="Pink"/>
                    <Setter Property="Foreground" Value="Black"/>
                </Trigger>
            </Style.Triggers>
            <Setter Property="Validation.ErrorTemplate">
                <Setter.Value>
                    <ControlTemplate>
                        <DockPanel LastChildFill="True"                    
                                   ToolTip="{Binding ElementName=controlWithError,Path=AdornedElement.(Validation.Errors)[0].ErrorContent}">
                            <Ellipse DockPanel.Dock="Right" 
                             ToolTip="{Binding ElementName=controlWithError, 
                                 Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"
                             Width="15" Height="15" 
                             Margin="-25,0,0,0"
                             StrokeThickness="1" Fill="IndianRed" >
                                <Ellipse.Stroke>
                                    <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                        <GradientStop Color="#FFFA0404" Offset="0"/>
                                        <GradientStop Color="#FFC9C7C7" Offset="1"/>
                                    </LinearGradientBrush>
                                </Ellipse.Stroke>
                                <Ellipse.Triggers>
                                    <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                                        <BeginStoryboard Storyboard="{StaticResource FlashErrorIcon}"/>
                                    </EventTrigger>
                                </Ellipse.Triggers>
                            </Ellipse>
                            <TextBlock DockPanel.Dock="Right" 
                            ToolTip="{Binding ElementName=controlWithError, 
                                 Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"
                            Foreground="White"
                            FontSize="10" 
                            Margin="-15,5,0,0" FontWeight="Bold">!
                        <TextBlock.Triggers>
                            <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                                <BeginStoryboard Storyboard="{StaticResource FlashErrorIcon}"/>
                            </EventTrigger>
                        </TextBlock.Triggers>
                            </TextBlock>
                            <Border BorderBrush="Red" BorderThickness="1">
                                <AdornedElementPlaceholder Name="controlWithError"/>
                            </Border>
                        </DockPanel>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Grid.Resources>

I tried to include in TextBox different ways, but I didn’t manage to do it. How to include this template?

    <TextBox>?????????What should I write here???????????>
     ?????????What should I write here???????????
    </TextBox>

How to turn on the template? Any help will be appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:49:24+00:00Added an answer on June 16, 2026 at 2:49 am

    You forgot to add the key textBoxInError to your TextBox style:

    <Grid.Resources>
        ...
        <Style x:Key="textBoxInError" TargetType="{x:Type TextBox}">
            ...
        </Style>
        ...
    </Grid.Resources>
    

    Without that key the Style is handled as default style for TextBox. In that case you would not explicitly reference a Style in your TextBox declaration, and would have to remove the Style="{StaticResource textBoxInError}" part.


    EDIT: If your Style is contained in a resource dictionary (like Grid.Resources in your XAML) and has a Key as shown above (textBoxInError), you would use that Style like this:

    <Grid>
        <Grid.Resources>
            <Style x:Key="textBoxInError" TargetType="{x:Type TextBox}">
            ...
            </Style>
            ...
        </Grid.Resources>
        ...
        <TextBox Style="{StaticResource textBoxInError}" ... />
    </Grid>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small I have just written which uses the following uri template.
I have some template classes I've written that are dependencies for several other classes
I have a template function in a shared library written in C++(the function is
I have written a form template to be used in different templates with the
I have previously written my web apps with a server side / html template
I have written a mail-processing program, which basically slaps a template on incoming mail
I have a JSON data object and a text/html javascript template written using the
Background I have written a test suite in mstest which has a template XML.
I have written a list-like template class sll (Single Linked List). Now, I am
I have written a function that retrieves a html template, then binds data using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.