Remove text after clicking in the textbox

后端 未结 8 898
孤独总比滥情好
孤独总比滥情好 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:21

    A XAML implementation that requires no code-behind. This is copied from the template of a custom control I built, and you'd probably want to make this a custom control yourself.

    The basic idea is that there are two TextBoxes in a Grid. The top one is the actual control that the user interacts with, but it's invisible (its 'Opacity' is zero) unless it contains text or has the focus. The bottom one contains the prompt text. It will only be visible when the TextBox on top of it is not, and it will never get the focus.

    You'll probably have to mess around with the binding on the editable TextBox, but this should get you started.

        
          
          
          
              
                  
              
          
      
    

提交回复
热议问题