I have a requirement which need the formatting of DateTime based on the system's language setting and the Currency symbol based on the user setting. The user setting is from a combo box where a user chooses the country. So, if the user chooses UK then the currency should be displayed in pounds and the date time should be displayed in US format.
For Example: If the System setting is US and the User setting is UK then the DateTime format needs to be in US and the Currency symbol to be £.
I have used this code to change the Culture info based on the system locale settings:
FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement),
new FrameworkPropertyMetadata(System.Windows.Markup.XmlLanguage.GetLanguage(
System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag
)
)
);
How do I format the currency symbol based on the user setting. I have used the culture formatting StringFormat=C2
through out the application and it displays the currency symbol based on the system's locale setting.
This application is WPF.
Some of the countries included in the combobox are: USA, Germany, UK, Canada
Edit:
I could use something like this. But is there a way to bind these culture info from my view model?
<StackPanel Margin="10">
<TextBlock Text="{Binding TotalPrice, StringFormat=C2, ConverterCulture='en-UK'/>
<TextBlock Text="{Binding TotalPrice, StringFormat=C2, ConverterCulture='en-US'/>
<TextBlock Text="{Binding TotalPrice, StringFormat=C2, ConverterCulture='de-DE'/>
</StackPanel>