A
A
Anton_repr2019-09-30 20:22:34
WPF
Anton_repr, 2019-09-30 20:22:34

How to clear textbox and passwordbox after clicking?

5d92393964865570593360.png
When the textbox is clicked, its initial content should be cleared.
I hung up the MouseLeftButtonDown event on the textbox and did this:

private void tb_click(object sender, MouseButtonEventArgs e)
        {
           textbox1.Text = "";
        }

But, unfortunately, nothing has changed. What am I doing wrong?
Using markup, prescribed - After double clicking it is deleted, I need after 1 MouseDoubleClick="tb_click"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
idShura, 2019-09-30
@Anton_repr

Use PreviewMouseLeftButtonDown

private void TextBox1_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
      TextBox1.Text = "";
 }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question