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 6783041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:49:02+00:00 2026-05-26T16:49:02+00:00

After trying numerous methods to get watermarking to work for me, I finally found

  • 0

After trying numerous methods to get watermarking to work for me, I finally found the one modified by @Beej on this page:
Watermark / hint text / placeholder TextBox in WPF

I got it placed in my project, and it works fine, with one exception. I have multiple textboxes on each tab of a tabcontrol. At the bottom is a clear button that works to clear all the textboxes on the tab. The clear button works fine, the watermark works fine, but I can’t get them to work together. The window loads with the watermarks in place, and pressing the clear button clears all the boxes, but the watermarks don’t reappear until after I move through the textboxes (each one gaining and losing focus.) I have tried numerous ways to solve this, such as placing a method call to the ShowWatermark function in the button MouseUp event, but nothing has worked…Help?!

This is the Clear button method I’m using:

    public void ClearTextBoxes()
    {
        ChildControls ccChildren = new ChildControls();

        foreach (object o in ccChildren.GetChildren(rvraDockPanel, 2))
        {
            if (o.GetType() == typeof(TextBox))
            {
                TextBox txt = (TextBox)o;
                txt.Text = "";
            }

            if (o.GetType() == typeof(DigitBox))
            {
                DigitBox digit = (DigitBox)o;
                digit.Text = "";
            }

            if (o.GetType() == typeof(PhoneBox))
            {
                PhoneBox phone = (PhoneBox)o;
                phone.Text = "";
            }

            if (o.GetType() == typeof(DateBox))
            {
                DateBox date = (DateBox)o;
                date.Text = "";
            }

            if (o.GetType() == typeof(TextBoxWatermarked))
            {
                TextBoxWatermarked water = (TextBoxWatermarked)o;
                water.Text = "";

            }
        }
    }

class ChildControls
{
    private List<object> listChildren;

    public List<object> GetChildren(Visual p_vParent, int p_nLevel)
    {
        if (p_vParent == null)
        {
            throw new ArgumentNullException("Element {0} is null!", p_vParent.ToString());
        }

        this.listChildren = new List<object>();

        this.GetChildControls(p_vParent, p_nLevel);

        return this.listChildren;

    }

    private void GetChildControls(Visual p_vParent, int p_nLevel)
    {
        int nChildCount = VisualTreeHelper.GetChildrenCount(p_vParent);

        for (int i = 0; i <= nChildCount - 1; i++)
        {
            Visual v = (Visual)VisualTreeHelper.GetChild(p_vParent, i);

            listChildren.Add((object)v);

            if (VisualTreeHelper.GetChildrenCount(v) > 0)
            {
                GetChildControls(v, p_nLevel + 1);
            }
        }
    }
}

Both the ChildControls class and the TextboxWatermarked class (from the above link) are in seperate class files.

  • 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-26T16:49:03+00:00Added an answer on May 26, 2026 at 4:49 pm

    The problem is not with your code, it’s with the chosen watermarked text box. It only updates the watermark when it gains or loses focus, which is an obvious flaw. You’ll need to find a better implementation. Have you tried the one in extended WPF toolkit?

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

Sidebar

Related Questions

[FIXED] After trying quite a few different solutions I finally got one to work.
After trying to get this to work for a while and searching around I
After trying everything I could, I finally created this test table: CREATE TABLE test_table
After trying to setup my site for Google Webmaster Tools I found that my
After trying to understand why client code is not rendered in a page (injected
After trying to get the mercurial repository explorer setup on my shared hosting with
I'm getting this error after trying to appendChild to an element that was just
I am very fresh to asp.net mvc and jQuery. After one day trying, I
I'm trying to get the html content of a page using silverlight. Webresponse and
I'm trying to populate a wxListCtrl but after trying various methods can't seem to

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.