Posted 28 October 2020, 6:41 pm EST
Hi Mark,
This behavior is by design in WPF as Binding doesn’t respect the CurrentCulture by default i.e it uses the neutral culture settings. Therefore, In order to make it use the current culture we have to set the Binding’s ConverterCulture property as follows:
<c1:DataGridNumericColumn Binding="{Binding Sale, ConverterCulture={x:Static glob:CultureInfo.CurrentCulture}}" Format="F" Header="Sale"></c1:DataGridNumericColumn>
Just in case needed you can also create a CustomBinding class so that you don’t have to set ConverterCulture everywhere as follows:
// C#
public class CustomBinding : Binding
{
public CustomBinding(string path) : base(path)
{
ConverterCulture = CultureInfo.CurrentCulture;
}
}
// XAML
<TextBox x:Name="txt" Margin="5" Width="100" Text="{local:CustomBinding Value}" HorizontalAlignment="Left"></TextBox>
Please refer the same from the attached sample. (see NumericFormat.zip)
Regards,
Kartik
NumericFormat.zip