I just got started programming for Windows Phone 7 after programming on Android for about half a year now. In Android, when I wanted textual input from a user, I would put a "hint" in the text box which would tell the user what they should input. When the text box was selected the hint would disappear. So far I've only seen ways to set text inside text boxes. The problem with this is that the text does not disappear when the user selects the text box forcing the user to erase the currently existing text.
I did some Google searches and skimmed through relevant documentation as well as a book I have but I've not found an answer yet. Thank you very much in advance for your time answering my question.
What you're looking for is normally called a "Watermarked" textbox. It's quite simple to create a control which implements this functionality.
Here are links to a few versions of implementations of this:
As I understand you want something similar to the default text in the searchbox (upper right corner of stackoverflow.com).
You have a few options.
Bool to check if user press the TextBox for the first time.
private bool m_textBoxPressedFirstTime = false;
and inside the event (double click the TextBox)
if(!m_textBoxPressedFirstTime)
{
myTextBox.Text = String.Empty;
m_textBoxPressedFirstTime = true;
}
Define your own template with a diffrent visual state.
You could use some WPF examples
How do you implement default text for a search box in WPF?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With