Column HeaderText Language Switch

Hello,
for my application it has to be possible to switch the language of the headertext of the columns in SfDataGrid during runtime. I have already implemented the Syncfusion.SfGrid.WPF.resx in englisch and german. For the filter in SfDataGrid the language switch is working. In which way do I have to bind the resource to the headertext so that this also works?
I have tried something like this, but nothing happens:
ColumnSizer="SizeToHeader"
TextAlignment="Center"
HeaderText="{DynamicResource ActivationTimeText}"
MappingName="ActivationTimeText" />
The text is definded in the resx-file like this:
///
/// Sucht eine lokalisierte Zeichenfolge, die Activationtime ähnelt.
///
public static string ActivationTimeText {
get {
return ResourceManager.GetString("ActivationTimeText", resourceCulture);
}
}
Thank you in advance!
Regards,
Nathalie

3 Replies

SJ Sathiyathanam Jeyakumar Syncfusion Team June 1, 2018 09:52 AM UTC

Hi Nathalie, 
 
Thank you for contacting syncfusion support. 
 
We have analyzed your query and achieve your requirement using the default Resources, 
And we define column header text resources and its value in the Resources.resx file and Bind the resource string into the xaml using the below code snippets. 
 
ResourceWrapper.cs 
 
public class ResourceWrapper 
{ 
        const string OrderIDTextName = "OrderIDText"; 
        const string CustomerIDTextName = "CustomerIDText"; 
        const string EmployeeIDTextName = "EmployeeIDText"; 
 
        public ResourceWrapper() 
        { 
            ResourceManager rs = LocalizationDemo.Properties.Resources.ResourceManager; 
            OrderIDText = rs.GetString(OrderIDTextName, CultureInfo.CurrentUICulture); 
            CustomerIDText = rs.GetString(CustomerIDTextName, CultureInfo.CurrentUICulture); 
            EmployeeIDText = rs.GetString(EmployeeIDTextName, CultureInfo.CurrentUICulture); 
        } 
 
        public string OrderIDText { get; set; } 
 
        public string CustomerIDText { get; set; } 
 
        public string EmployeeIDText { get; set; } 
 
} 
 
MainWindow.xaml 
// Define the Resource Wrapper 
<syncfusion:ChromelessWindow.Resources> 
        <local:ResourceWrapper x:Key="resourceWrapper"/> 
</syncfusion:ChromelessWindow.Resources> 
 
 
// Bind the values to the column Header Text. 
 
<syncfusion:GridTextColumn  
HeaderText="{Binding Path=OrderIDText,Source={StaticResource resourceWrapper}}" 
                                               MappingName="OrderID" 
                                               TextAlignment="Right" /> 
<syncfusion:GridTextColumn  
HeaderText="{Binding Path=CustomerIDText,Source={StaticResource resourceWrapper}}"  
                                               MappingName="CustomerID" /> 
<syncfusion:GridTextColumn  
HeaderText="{Binding Path=EmployeeIDText,Source={StaticResource resourceWrapper}}" 
                                               MappingName="EmployeeID" 
                                               TextAlignment="Right" /> 
 
 
You can download the sample from the below location. 
 
You can get more details about localization from the below links. 
 
 
 
Please let us know if you have any future assistance on this. 
 
 
Regards, 
Sathiyathanam 



NK Nathalie Kreis June 5, 2018 11:54 AM UTC

Hello Sathiyathanam,

thank you for your reply. My problem was only partially resolved by the answer. The thing is that I want to change between the German and the English language during runtime. In the ResourceWrapper.cs itself this also works via the property "CurrentCulture", the text changes between the german and the english word. The problem now is that the HeaderText in the SfDataGridTextColumn is not updated. The header seems not even get to know that the text has been changed. Do you still have a solution for this?

Thank you in advance.


Regards,

Nathalie


SJ Sathiyathanam Jeyakumar Syncfusion Team June 7, 2018 03:54 AM UTC

Hi Nathalie, 
We have analyzed your query and achieve your requirement using the below code snippets. Now you can able to change the resource at runtime. We have change the resource when click the button. 
Code snippet C#. 
##Button Click Codes 
 
private void button_Click(object sender, RoutedEventArgs e) 
{ 
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ge"); 
            ResourceWrapper wrapper = this.Resources["resourceWrapper"] as ResourceWrapper; 
            if(wrapper!= null) 
            { 
                wrapper.SetResource(LocalizationDemo.Properties.Resources_ge.ResourceManager); 
                wrapper.OnPropertyChanged(""); 
            } 
} 
 
 
 
// Get the localized string value using the Resource Manger. 
 
public string OrderIDText 
{ 
            get 
            { 
               return  rs.GetString(OrderIDTextName, CultureInfo.CurrentUICulture); 
            } 
             
 } 
 
 
You can download the modified sample from the below location. 
 
 
Regards, 
Sathiyathanam 


Loader.
Up arrow icon