WPF Xaml StringFormat

Posted on

Question :

Good afternoon guys, I have a somewhat ridiculous problem, but I can not find the solution.

I’m trying some stringFormat as StringFormat={}{0:#,#.00}} and StringFormat=N2} , in addition to StringFormat='c' , but taking the first one that does not compile (I do not know why) the others enter 2 decimal places (value + 00) but I’d like him to consider the last two houses of value as the pennies.

<DataGridTextColumn Header="Valor Fator" Binding="{Binding 
PendenciaValorFator, Mode=TwoWay, StringFormat=N2, 
UpdateSourceTrigger=PropertyChanged}" IsReadOnly="False">

I am sending a decimal with this format: 728001 and it is showing 728.001, but I would like it to display 7,280.01.

Adding, I need to be sent a numeric value for the grid otherwise when I make the “order” it will do so by string, first placing the value 1,111.11 instead of 999.99.


Answer :

In order for the resulting string to have decimal places as desired, the source value, in this case PendenciaValorFator , must represent this value with those decimal places.

That is, for the result to be "7280.01" it is necessary that PendenciaValorFator is equal to 7280.01 and not 728001 .


Leave a Reply

Your email address will not be published. Required fields are marked *