Textbox changes the value to decimal (EN) when pressing the TAB, however I want to leave currency (REAL) the field

Asked

Viewed 72 times

3

I have a field

 <TextBox x:Name="TbTotalICMS" Style="{StaticResource MeuTextBoxValor}" Text="{Binding Vicms}" />

My Vicms is a decimal. By pressing the TAB key, the value that is 1.00 (example) it turns 100. For as he is a decimal in English he takes out the comma and swaps it for a point. I need that when pressing the TAB it continues like this.

2 answers

1

In the event of LostFocus there is always the possibility to convert/force the value to the format we want:

NumberFormatInfo numberFormatInfo = new NumberFormatInfo();

// número de casas decimais
numberFormatInfo.NumberDecimalDigits = 2;
// separador de casas decimais
numberFormatInfo.NumberDecimalSeparator = ",";
// separador de milhares
numberFormatInfo.NumberGroupSeparator = ".";
string value = DoubleValue.ToString("N", numberFormatInfo);

1


I solved this by putting a Converterculture!

 <TextBox x:Name="TbTotalICMS" Style="{StaticResource MeuTextBoxValor}" Text="{Binding Vicms,  ConverterCulture='pt-BR'}" />

Browser other questions tagged

You are not signed in. Login or sign up in order to post.