What is the difference between these three ways to clear a Textbox?

前端 未结 10 711
孤城傲影
孤城傲影 2021-02-01 17:11

I am bit confused between the below three ways to clear the contents of a textbox. I am working with WPF and found All are working, but I am unable to find the difference.

10条回答
  •  天命终不由人
    2021-02-01 17:30

    If you are behind some performance differences or memory leaks, there are not much (just some additional calls to events when setting text instead of using .Clear() )

    However, you dont have access to control itself when using MVVM, so only way to clear the text is by setting text to binded property with TextBox.

    In standard application, you can do whatever you want (I will prefer using .Clear() method which is designed for this purpose).

提交回复
热议问题