I want to show a placeholder text in TextBox
when user hasn\'t typed anything and TextBox
is idle.
In Andriod it can be done using a
Edit for windows-8.1 they have introduced a new property
Please see Sergey Aldoukhov's answer
For me this is the working solution that I got.
If any one has better solution please answer.
private void OnTestTextBoxGotFocus(object sender, RoutedEventArgs e)
{
if (testTextBox.Text.Equals("Type here...", StringComparison.OrdinalIgnoreCase))
{
testTextBox.Text = string.Empty;
}
}
private void OnTestTextBoxLostFocus(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(testTextBox.Text))
{
testTextBox.Text = "Type here...";
}
}
MS also do the same check the example here.
P.S. I have created a custom control for TextBox
you can download it from here