Binding to double field with validation

前端 未结 6 937
时光说笑
时光说笑 2020-12-30 04:13

I\'m trying to bind TextBox to double property of some object with UpdateSourceTrigger=PropertyChanged. The goal is to immediately dur

6条回答
  •  离开以前
    2020-12-30 04:29

    The problem is that you are updating your property every time the value changes. When you change 12.03 to 12.0 it is rounded to 12.

    You can see changes by providing delay by changing the TextBox in xaml like this

    
    

    but delay will notify and set the property after the delay time in mili sec. Better use StringFormat like this

    
    

提交回复
热议问题