Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String Localisation Problem in Silverlight Application

I have an odd problem in silverlight. I use the following XAML to bind the content of a label to a double property in my viewmodel.

Content="{Binding FeePeriodActual, Mode=OneWay,StringFormat=\{0:c\}}"

However, the display string always shows the $ Dollar Currency symbol rather than the the £. This is the same on the production server and the dev machine. All localisation properties are set right on the webserver(s). I can't see where to change it in the silverlight app.

Anyone got any ideas?

like image 977
Dave Stringer Avatar asked Dec 14 '25 20:12

Dave Stringer


1 Answers

Modify the Application_Startup method in App.xaml.cs to look like this:-

private void Application_Startup(object sender, StartupEventArgs e)
{
  Resources.Add("DefaultCulture", System.Globalization.CultureInfo.CurrentCulture);

  this.RootVisual = new MainPage();
}

Now where you need culture specific formatting in bindings use:-

Content="{Binding FeePeriodActual, Mode=OneWay,StringFormat=\{0:c\}, ConverterCulture={StaticResource DefaultCulture}}"
like image 60
AnthonyWJones Avatar answered Dec 17 '25 11:12

AnthonyWJones



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!