When you activate an application, a textbox with text \"hello\" will appear.
My question is:
When you click on the textbox in order to make input data, I want to rem
To expound upon Donut's answer so that your textbox will keep the text a user inputs unless it's purely whitespace, here's a solution that I use:
XAML
C#
void TextBox_GotFocus( object sender, RoutedEventArgs e )
{
TextBox box = sender as TextBox;
box.Text = string.Empty;
box.Foreground = Brushes.Black;
box.GotFocus -= TextBox_GotFocus;
}
void TextBox.LostFocus( object sender, RoutedEventArgs e )
{
TextBox box = sender as TextBox;
if( box.Text.Trim().Equals( string.Empty ) )
{
box.Text = "Search...";
box.Foreground = Brushes.LightGray;
box.GotFocus += TextBox_GotFocus;
}
}