How can I put some text into a textbox which is removed automatically when user types something in it? (In WPF)
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Carriage Return (ASCII chr 13) is missing from tex
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
I can't believe that no one posted the obvious Extended WPF Toolkit - WatermarkTextBox from Xceed. It works quite well and is open source in case you want to customise.
Simple solution using style:
Great solution:
https://code.msdn.microsoft.com/windowsdesktop/In-place-hit-messages-for-18db3a6c
I have created siple code-only implementation which works fine for WPF and Silverlight as well:
Usage:
Here's my approach Is great for MVVM where I also check if the Text box has focus, you can also use a regular trigger just for the text value as well the point is I just change the background Image when value changes:
This can help check it with your code.When applied to password box,it will show Password,which will disappear when usertypes.
Just using XAML, no extensions, no converters: