Culture Support

With the Q2 2014 release version of UI for Silverlight, the LocalDataSourceProvider provides a brand new Culture support option. Now it is possible to localize the underlying data using the CurrentCulture of the user or any other Culture. For example, this will allow you to display the names of the Months in the desired language, use the currency symbol from the specified culture and format the values with the correct separator.

Setting LocalDataSourceProvider Culture

You can easily apply the required culture by setting the Culture property of the LocalDataSourceProvider as shown below:

<pivot:LocalDataSourceProvider x:Key="LocalDataProvider" Culture="en-US"> 
    ... 
</pivot:LocalDataSourceProvider> 

var dataProvider = new LocalDataSourceProvider { Culture = new CultureInfo("en-US") }; 
Dim dataProvider = New LocalDataSourceProvider With {.Culture = New CultureInfo("en-US")} 

By default when there isn't any Culture set the LocalDataSourceProvider will use InvariantCulture to display the data. In this case as a currency symbol will be displayed the one from the CurrentCulture.

On the following screenshots you can see how setting different cultures will affect the displayed data.

Figure 1: Culture="en-US" Rad Pivot Grid Features Culture Support 01

Figure 2: Culture="fr-FR" Rad Pivot Grid Features Culture Support 02

Figure 3: Without any Culture set (using the CurrentCulture for the currency symbol) Rad Pivot Grid Features Culture Support 03

Changing LocalDataSourceProvider Culture at Runtime

If you would like to change the Culture at runtime you will need to manualy reset the ItemsSource of the LocalDataSourceProvider and set the new Culture. For example, if the LocalDataSourceProvider is defined in XAML you will be able to easily change the Culture as shown below:

var provider = this.Resources["LocalDataProvider"] as LocalDataSourceProvider; 
var itemsSource = provider.ItemsSource; 
provider.ItemsSource = null; 
provider.Culture = new CultureInfo("fr-FR"); 
provider.ItemsSource = itemsSource; 
Dim provider = TryCast(Me.Resources("LocalDataProvider"), LocalDataSourceProvider) 
Dim itemsSource = provider.ItemsSource 
provider.ItemsSource = Nothing 
provider.Culture = New CultureInfo("fr-FR") 
provider.ItemsSource = itemsSource 

See Also

In this article