WPF C # String Format

2

I have a usercontrol with the following configuration:

<UserControl x:Class="PainelPendencias.View.PendenciaConsulta"
             x:Name="uCPendenciaConsulta"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             xml:lang="pt-BR"
             d:DesignHeight="720"  d:DesignWidth="1024">

In a DataGrid column I make the stringformat below:

<DataGridTextColumn Header="Valor" Binding="{Binding OperacaoValor, StringFormat=N}" IsReadOnly="True">

The received value to be formatted is: 100543.67M.

The problem is that on some machines it is being shown correctly: 100.543,67 and in others it is adding zeros: 10,054,367.00.

[Update] On the machine that is formatted incorrectly I went into the regional settings and removed the addition of 2 decimal places [palliative]. But on machines that work this addition does exist.

    
asked by anonymous 20.12.2016 / 14:48

2 answers

3

Have you tried other means of number formatting? See more other examples.

<DataGridTextColumn Header="Valor" Binding="{Binding OperacaoValor, StringFormat={}{0:#,#.00}}" IsReadOnly="True">
<DataGridTextColumn Header="Valor" Binding="{Binding OperacaoValor, StringFormat={0:#,0} {1:#,0}}" IsReadOnly="True">
<DataGridTextColumn Header="Valor" Binding="{Binding OperacaoValor, StringFormat=\{0:N0\}}" IsReadOnly="True">
<DataGridTextColumn Header="Valor" Binding="{Binding OperacaoValor, StringFormat={}{0:N0}}" IsReadOnly="True">

Response update

<DataGridTextColumn Header="Valor" Binding="{Binding OperacaoValor, StringFormat='#,##0.00', ConverterCulture='pt-BR'}" IsReadOnly="True">
    
20.12.2016 / 15:10
1

Try ConverterCulture = en like this:

<DataGridTextColumn Header="Valor" Binding="{Binding OperacaoValor, ConverterCulture=pt-BR}" IsReadOnly="True">
    
05.06.2018 / 01:09