Placeholder textbox wpf

Diego Alvarez 101 Reputation points
2020-07-02T18:26:40.217+00:00

Is there a property, tag or element that allows adding placeholders to textboxes in WPF?

Thank you.

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,784 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ken Tucker 5,856 Reputation points
    2020-07-04T23:32:29.113+00:00

    I think you are looking to put a watermark in the textbox. Here is an article which shows how

    https://learn.microsoft.com/en-us/dotnet/framework/wpf/controls/how-to-add-a-watermark-to-a-textbox

    1 person found this answer helpful.
    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Sabrina Cosolo 126 Reputation points
    2020-07-03T10:52:44.743+00:00

    From what I can understand of your Question, you are asking if there is a Way to add a Placeholder to a Textbox in WPF,
    the WPF controls have all a Tag property where you can set an object attached to the control, but if the Placeholder is something you need to find the control you can use the property x:Name to give it a name in XAML and then from the csharp class you can find your Textbox by name

    <TextBox n:Name="MyTextbox" />

    in xaml

    MyTextbox.Text = "This is the text";

    is how to assign a text to the textbox from code.

    HTH
    Sabrina

    0 comments No comments

  2. Diego Alvarez 101 Reputation points
    2020-07-03T20:31:44.133+00:00

    I need to put a predefined text in the textbox. This text disappears when the textbox is clicked

    0 comments No comments

  3. Diego Alvarez 101 Reputation points
    2020-07-05T16:44:57.077+00:00

    Thanks for the reply. This is what I need.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.