简体   繁体   中英

String Currency Format not using correct Local

I am currently working on a C# project and I am formatting the data within a cell within a WPF datagrid to be shown as a currency.

In the datagrid I am using the following code:

<my:DataGridTemplateColumn Header="Debit Amount">
     <my:DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
           <TextBlock Text="{Binding DebitAmount, StringFormat='C'}" />
        </DataTemplate>
     </my:DataGridTemplateColumn.CellTemplate>
</my:DataGridTemplateColumn>

When the string is formatted it is displaying it as $50.00 but it should be displaying £50.00. I thought maybe I'd forgotten to change the language settings on my PC and left it as the default US instead of changing it to UK, however, the PC is set up to be English UK.

Is there a way I can force it to either be UK or format it based on the language settings of the PC.

Thanks for any help you can provide.

You have to set the xml:lang attribute in your XAML. Add the attribute xml:lang="en-GB" to your top-level XAML element.

For more information you can read about xml:lang Handling in XAML .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM