This is a migrated thread and some comments may be shown as answers.

Culture of data in GridView

4 Answers 152 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
Patrick asked on 05 Nov 2012, 01:42 PM
Hello,
with the previous version (.912) of RadGridView, it was easy to change the culture of the application: a single call to
Thread.CurrentThread.CurrentCulture = new CultureInfo("xxx");
changes the culture for the whole application.
In the last version (.1017), it seems that now the formatting is made in another thread and that the culture is no more taken into account!

If you create a new Silverlight 5 application and

Create a new class MyData.cs with:
using System;
 
namespace RadControlsSilverlightApp1
{
  public class MyData
  {
    public DateTime DateTime {get; set;}
  }
}

Replace MainPage.xaml.cs with:
using System;
using System.Globalization;
using System.Threading;
using System.Windows.Controls;
 
namespace RadControlsSilverlightApp1
{
  public partial class MainPage : UserControl
  {
    public MainPage()
    {
      InitializeComponent();
      Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-fr");
 
      var Data = new MyData[100];
      var DT   = DateTime.Now;
      var Rnd  = new Random();
      for (Int32 ix = 0; ix < 100; ix++)
      {
        Data[ix] = new MyData () {DateTime = DT};
        DT = DT.AddSeconds(Rnd.Next(60 * 60 * 24));
      }
 
      GridView.ItemsSource = Data;
    }
  }
}

and MainPage.xaml with:
<UserControl
  x:Class="RadControlsSilverlightApp1.MainPage"
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
    <Grid Margin="5">
   <telerik:RadGridView Name="GridView"
                        AutoGenerateColumns="False">
     <telerik:RadGridView.Columns>
       <telerik:GridViewDataColumn DataFormatString="G"
                                   DataMemberBinding="{Binding DateTime}"
                                   Header="Date"
                                   Width="150" />
     </telerik:RadGridView.Columns>
   </telerik:RadGridView>
    </Grid>
</UserControl>

Now, run the application and see that the dates are still displayed in US format!

Patrick

4 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 05 Nov 2012, 02:55 PM
Hi,

Thank you for the detailed description. You could check this forum thread where a similar question is discussed.

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
answered on 05 Nov 2012, 03:48 PM
Didie,
it doesnt't work the same in Silverlight, but I've got it.
In App.xaml.cs, you must add:
((FrameworkElement) RootVisual).Language = XmlLanguage.GetLanguage ("<LanguageCode>");
After setting the RootVisual property.

But, if you had take a default value of Thread.CurrentThread.CurrentCulture for Language, no application would be broken.

Patrick
0
Dimitrina
Telerik team
answered on 06 Nov 2012, 08:52 AM
Hi,

You could as well check this troubleshooting article. The behaviour is like so as we have tried to be consistent with the DataGrid. 

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Dimitrina
Telerik team
answered on 08 Feb 2013, 04:18 PM
Hello,

In addition to my last answer, I would like to inform you that we have introduced a new property IsLocalizationLanguageRespected of the RadGridView especially for such cases. It is available in our latest internal build. 

Its default value is 'true' meaning that the formatting will be based on the Language property (default behaviour). Once you set it to 'false", then the CurrentCulture will be respected. 
 

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Dimitrina
Telerik team
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or