An issue when TextBox is binding to double and enter negative number that little than -1

后端 未结 2 1123
孤街浪徒
孤街浪徒 2021-01-24 02:07

I have an issue when i binding a textbox to Propery and enter a negative number that is less than -1 - for example -0.45:

the textbox:



        
2条回答
  •  走了就别回头了
    2021-01-24 02:27

    when you enter the decimal value it becomes 0 again so the best way to do this is using the lostfocus trigger:

     
    

    Also you need to do this in the view model:

    public double Txt
        {
            get { return txt; }
            set
            {
                if (!txt.Equals(value))
                {
    
                    txt = value;
                    OnPropertyChanged("Txt");
                }
            }
        }
    

提交回复
热议问题