Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextBox Won't Allow me to enter in a decimal

Tags:

c#

xaml

I can Enter Numbers into the text box but it won't allow me to enter decimal values. May I ask why is this?

<TextBox Text="{Binding SebAmountPer, Mode=Twoway, UpdateSourceTrigger=PropertyChanged}" Grid.Column="1" Grid.Row="2" TextWrapping="Wrap"/>

public decimal? SebAmountPer
{
    get
    {
        return _seb.SEBAmountPer;
    }
    set
    {
        _seb.SEBAmountPer = value; 
        OnPropertyChanged("SebAmountPer");
        OnPropertyChanged("SebTotal");
    }
}
like image 326
Master Avatar asked Sep 15 '25 06:09

Master


1 Answers

You have a two-way binding to a numeric datatype. The trigger is property change which means after every key stroke. Try binding to a string first or change update trigger.

You enter "2." and he updates the binding to 2.0 and converts it back and just steals away your dot ;)

like image 148
ZoolWay Avatar answered Sep 17 '25 18:09

ZoolWay