How can I put some text into a TextBox which is removed automatically when user types something in it?
This technique uses the Background property to show / hide placeholder textbox.
Placeholder is shown event when Textbox has the focus
How it works:
Here is basic example. For my own purposes I turned this into a UserControl.
Here is the ValueConverter to detect non-empty strings in the DataTrigger.
public class NotEmptyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var s = value as string;
return string.IsNullOrEmpty(s);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return null;
}
}