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

  • Home
  • SEARCH
  • 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 6071391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:02:30+00:00 2026-05-23T10:02:30+00:00

I script-kiddied this code to show helper text in a field before the field

  • 0

I script-kiddied this code to show helper text in a field before the field is populated by the user (also plan on using some modification of it to show the validation error if one occurs), but the trigger isn’t, well, triggering. What’s wrong with this code?

xaml:

<TextBox x:Name="firstName" Validation.Error="Text_ValidationError"
             Text="{Binding UpdateSourceTrigger=LostFocus, Path=firstName, ValidatesOnDataErrors=true, NotifyOnValidationError=true}" Margin="30,12,50,245">
        <TextBox.Style>
            <Style TargetType="TextBox" >
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Path=firstName}" Value="">
                        <Setter Property="Background">
                            <Setter.Value>
                                <VisualBrush Stretch="None">
                                    <VisualBrush.Visual>
                                        <TextBlock Text="First name" />
                                    </VisualBrush.Visual>
                                </VisualBrush>
                            </Setter.Value>
                        </Setter>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </TextBox.Style>
    </TextBox>
  • 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-05-23T10:02:31+00:00Added an answer on May 23, 2026 at 10:02 am

    Don’t use a DataTrigger for this, it’s not necessary (the binding might be broken, in fact that is the only thing that i can think of that might cause this not to work), use a normal Trigger:

    <Trigger Property="Text" Value="">
        <Setter Property="Background">
            <Setter.Value>
                <VisualBrush Stretch="None">
                    <VisualBrush.Visual>
                        <TextBlock Text="First name" />
                    </VisualBrush.Visual>
                </VisualBrush>
            </Setter.Value>
        </Setter>
    </Trigger>
    

    Tested this, it works. This also has the advantage that the background disappears immediately when the user starts typing rather than when the focus on the control is lost and the source string is updated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Script adds id for block, gives: <div id=some>Text</div> After that page should jump for
The script below resides in my theme's functions.php file. It is designed to show
The script below worked on my Mac OS X. I'm now using Ubuntu OS,
Script replaces rel attributes to class . Full code - http://jsbin.com/efozi3/8/ It doesn't work
This script works with and without XPathContext . Why should I use it with
This script: <?php $lines[] = ''; $lines[] = 'first line '; $lines[] = 'second
my script.php returns this XML <all> <item> <field1>value1</field1> <field2>value2</field2> </item> <item> <field1>value1</field1> <field2>value2</field2> </item>
This script is to connect to different servers and copy a file from a
This script work perfectly, but what it does is stops an instance of a
This script seems to get hung up when it hits the series of if

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.