Remove text after clicking in the textbox

后端 未结 8 895
孤独总比滥情好
孤独总比滥情好 2021-02-02 18:03

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

8条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-02 18:24

    Please don't over complicate the answer several ways to skin a cat but, less code the better I would presume.

    Petermac's option is the way to go for me.

    Add "GotFocus" in the main Xaml window to the control eg."textbox"

        private void Filename_GotFocus(object sender, RoutedEventArgs e)
        {
            Filename.Text = "";            
        }
    

    or I like this option

        private void Filename_GotFocus(object sender, RoutedEventArgs e)
        {
            Filename.clear();            
        }
    

    the question asked was just to empty the textbox.

提交回复
热议问题