wpf Datagrid currency is alway $

1k Views Asked by At

Im making a receipt for a fast food . one column is for price which i try to set it's as currency in xaml like this

 <DataGridTextColumn Header="MenuPrice" x:Name="MenuPrice" 
                                        Binding="{Binding MenuPrice, StringFormat=C2}" Width="100" />

In other places i get euro sign but only in datagrids i get it as dollar . how can i change it to actually follow the users windows configuration ? like other places.

enter image description here

if you see at the buttom i have a label which is the result of total like this

total.toString("c2");

and i get the euro sign but not in datagrid

2

There are 2 best solutions below

1
On BEST ANSWER

I believe this is basically a duplicate of this question.

The chosen answer states:

I'm not sure if this has been fixed in .NET 4, but WPF has never picked up the current culture when rendering things like currency or dates.

It also gives a solution.

0
On

Set the Language property of the DataGrid to your thread's current culture:

yourDataGrid.Language = System.Windows.Markup.XmlLanguage.GetLanguage(System.Threading.Thread.CurrentThread.CurrentCulture.IetfLanguageTag);

I am afraid you cannot do this in pure XAML.