1

Hi I have one textbox and one passwordBox in my UI. Now I want to display "Enter User Name" in the textbox and want to display "Enter Password" in the passwordBox for very known reason. But I have seen that this option is missing in PasswordBox.

Right now my approach is to another textbox in the same position as the passwordBox and in gotFocus event flip the controls. But just want to know is there any other way I can do that?

By default passwordBox contains no string.

I need this feature fro windows phone apps, and the example all of you provided is fine but doesn't work with Windows phone as there is no . Anyhow thanks for the answers from all of you. But could you please provide solution keeping in mind Windows phone features

Debhere
  • 1,055
  • 2
  • 19
  • 41
  • if you don't mind using a library look at MahApps and the watermark it attaches to standard TextBox http://mahapps.com/MahApps.Metro/#textbox – kenny Feb 18 '13 at 18:20

3 Answers3

4

You can create a style for your passwordbox. Check below link

http://prabu-guru.blogspot.in/2010/06/how-to-add-watermark-text-to-textbox.html

Mukesh Rawat
  • 2,047
  • 16
  • 30
  • Thanks for this link but can I do this in Windows phone 8 apps? API s are different for Win Phone and WPF. – Debhere Feb 19 '13 at 17:49
  • Yes it will work, all you have to do is create a WaterMark helper class and use that in the style for passwordBox. – Mukesh Rawat Feb 20 '13 at 06:24
  • I have tried the link for PasswordBox control for Windows phone, but it is not working, there less control in WP8, like ControlTemplate.Triggers are not there and I have searched some more here and there but no luck. It seems to work in WPF with Windows but not with WP7 or Windows Phone 8 – Debhere Feb 22 '13 at 08:25
0

Actually, It is not possible to show text Enter Password in PasswordBox. Usually to show users to enter Password it is shown as:

Pwd Box

and you can set hover text with Enter Password.

Community
  • 1
  • 1
Zaheer Ahmed
  • 28,160
  • 11
  • 74
  • 110
0

You most definitely can by creating a new control template and set some triggers in it.

See this SO post

Community
  • 1
  • 1
Sten Petrov
  • 10,943
  • 1
  • 41
  • 61