Bind textbox to float value. Unable to input dot / comma
.net, c#, wpf
Solution
Try adding a StringFormat definition to the binding. Like so:
<TextBox Name="txtPower" Height="23"
TextWrapping="Wrap" Text="{Binding Path=Power, Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged,StringFormat=N2}"></TextBox>
Problem
When I try to input a DOT or a COMMA in a textbox, for example `1.02` or `83,33` the textbox prevents me to input such a value (and the input turns red). The textbox is bound to a float property. Why? I have bound a textbox to a float Property `Power` of a class implementing `INotifyPropertyChanged`. ``` private float _power; public float Power { get { return _power; } set { _power = value; OnPropertyChanged("Power"); } } ``` In Xaml ``` <TextBox Name="txtPower" Height="23" TextWrapping="Wrap" Text="{Binding Path=Power, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox> ``` I have no custom validation at all right now. Also tried decimal but it does not work either. For string everything works fine.