Вопрос

I want to Empty The Text which is by default written in the textbox , i can empty it by doing

Textbox1.Text="";

but i want to know, which event should i exactly use ?will it be GotFocus,KeyEnter,Keyup,Tap or any other method .

Это было полезно?

Решение

One simple way is using on GotFocus and LostFocus. On GotFocus the code should be something like this:

if (textbox1.Text == "My default text...")
            textbox1.Text = "";

Just to make sure to no delete a text previously entered by the user. And on LostFocus just something like this:

if (String.IsNullOrWhiteSpace(textbox1.Text))
            textbox1.Text = "My default text...";

So again you are checking to no delete a user entered text.

Hope this helps

Другие советы

You can use PhoneTextBox of WPToolkit, which will maintain that functionality on its own

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top