New to Telerik UI for WPF? Download free 30-day trial

How to Respect Application's CurrentCulture in Custom Format Strings

Currently the culture used for formattng the data in RadGridView is the one specified as a Language for it (or for the containing Window/UserControl). We have changed this behaviour with version Q2 2012 SP2, so now it is compatible with the behaviour of the MS DataGrid.

Still, there is a way to set the CurrentCulture and apply the format you would like to. With Q1 2013 we have introduced a new property of RadGridView - IsLocalizationLanguageRespected. You can use it to control whether CurrentCulture or Language is respected. Please note that by default the Language will be respected, so you will need to set it to False so that your custom format can take effect.

Example 1 demonstrates how you can define custom formatting with the help of the CurrentCulture.

Example 1: Defining custom formatting

System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo("en-US"); 
System.Globalization.DateTimeFormatInfo dateTimeInfo = 
new System.Globalization.DateTimeFormatInfo(); 
dateTimeInfo.LongDatePattern = "dd--MMM--yyyy"; 
dateTimeInfo.ShortDatePattern = "dd--MMM--yy"; 
cultureInfo.DateTimeFormat = dateTimeInfo; 
cultureInfo.NumberFormat.NumberGroupSeparator = "/"; 
cultureInfo.NumberFormat.NegativeSign = "/"; 
 
Thread.CurrentThread.CurrentCulture = cultureInfo; 
Thread.CurrentThread.CurrentUICulture = cultureInfo; 
Dim cultureInfo As New System.Globalization.CultureInfo("en-US") 
Dim dateTimeInfo As New System.Globalization.DateTimeFormatInfo() 
dateTimeInfo.LongDatePattern = "dd--MMM--yyyy" 
dateTimeInfo.ShortDatePattern = "dd--MMM--yy" 
cultureInfo.DateTimeFormat = dateTimeInfo 
cultureInfo.NumberFormat.NumberGroupSeparator = "/" 
cultureInfo.NumberFormat.NegativeSign = "/" 
 
Thread.CurrentThread.CurrentCulture = cultureInfo 
Thread.CurrentThread.CurrentUICulture = cultureInfo 

Figure 1: RadGridView displaying data with IsLocalizationLanguageRespected set to True

Telerik WPF DataGrid customformat before

Figure 2: RadGridView displaying data with IsLocalizationLanguageRespected set to False

Telerik WPF DataGrid customformat after

See Also

In this article