locked
Number Group separator not shown in Datagrid cell RRS feed

  • Question

  • Hello,

    I am using the Datagrid. I have set the Framework elements to take the culture info from system during app startup by setting the FrameworkElement.LanguageProperty.OverrideMetadata

     I can see that the decimal separators are displayed correctly based on the culture info but the number group separators are not displayed. Why is the number group separator ignored? Can anyone advise how I can enable the visibility of number group separator set in culture info.

    Friday, June 13, 2014 5:46 PM

Answers

  • You could set the ConverterCulture property of the binding. Please refer to the following example where "Price" is a float property:

    <DataGrid ItemsSource="{Binding Items}" AutoGenerateColumns="False" xmlns:gl="clr-namespace:System.Globalization;assembly=mscorlib">
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding Name}"/>
                    <DataGridTextColumn Binding="{Binding Price, StringFormat=N2, ConverterCulture={x:Static gl:CultureInfo.CurrentCulture}}"/>
                </DataGrid.Columns>
            </DataGrid>
    

    • Marked as answer by Yang,Chenfei Friday, June 20, 2014 1:57 AM
    Sunday, June 15, 2014 6:45 PM

All replies

  • I think you would do best showing us exactly what you're doing.

    When  you set the culture info, how do you do that?

    When you format the stuff you're showing, how do you do that? 

    When you run it and get the culture info, what does it return and what happens if you set it to something else?

    Sunday, June 15, 2014 2:27 PM
  • You could set the ConverterCulture property of the binding. Please refer to the following example where "Price" is a float property:

    <DataGrid ItemsSource="{Binding Items}" AutoGenerateColumns="False" xmlns:gl="clr-namespace:System.Globalization;assembly=mscorlib">
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding Name}"/>
                    <DataGridTextColumn Binding="{Binding Price, StringFormat=N2, ConverterCulture={x:Static gl:CultureInfo.CurrentCulture}}"/>
                </DataGrid.Columns>
            </DataGrid>
    

    • Marked as answer by Yang,Chenfei Friday, June 20, 2014 1:57 AM
    Sunday, June 15, 2014 6:45 PM