TextBox mascara value from 2 to 4 decimal places in WPF C #

3

I would like my TextBox to have the following "mask" When I put two houses after the comma:

  

0.00

or when I put three:

  

0.000

or when I put 4:

  

0.0000

My code in WPF C # is the following:

 <TextBox  x:Name="ValorProdutoTextBox"  
  Text="{Binding ValorProduto, NotifyOnValidationError=true,
  ValidatesOnExceptions=true,  ConverterCulture='pt-BR'}"
  UpdateSourceTrigger="ValorLostFocus"
   Height="20"
   Width="100" Margin="1" />

The result is always coming as determined by the 'Binding ValueProduct' that is in the database (DECIMAL 15,4)

  

0.0000

    
asked by anonymous 15.08.2018 / 21:22

1 answer

2

Here is the code example:

<TextBox Text="{Binding Value, StringFormat=N2}" />
<TextBox Text="{Binding Value, StringFormat={}{0:#,#.00}}" />

Original answer: StackOverFlow English

    
15.08.2018 / 22:26