Localization in WPF TreeGrid (SfTreeGrid)

10 Nov 20232 minutes to read

Localization is the process of translating the application resources into different language for the specific cultures. You can localize the treegrid by adding resource file. Application culture can be changed by setting CurrentUICulture before InitializeComponent method.

Below application culture changed to German.

public MainWindow()
    System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de");

Localize the drag and drop window text in treegrid

To localize the treegrid, drag and drop window based on CurrentUICulture using resource files, follow the below steps.

1.Create new folder and named as Resources in your application. 

2.Add the default resource file of treegrid into Resources folder. You can download the Syncfusion.SfGrid.WPF.resx here.

WPF TreeGrid with Resouce File

3.Right-click on the Resources folder, select Add and then NewItem.

4.In Add New Item wizard, select the Resource File option and name the filename as Syncfusion.SfGrid.WPF.<culture name>.resx. For example, you have to give name as Syncfusion.SfGrid.WPF.de.resx for German culture.

5.The culture name that indicates the name of language and country.

Creating Resource File for WPF TreeGrid

6.Now, select Add option to add the resource file in Resources folder.

Adding Created Resource File as Resource for WPF TreeGrid

7.Add the Name/Value pair in Resource Designer of Syncfusion.SfGrid.WPF.de.resx file and change its corresponding value to corresponding culture.

Changing Resource Dile as per Culture in WPF TreeGrid

WPF TreeGrid displays Drag and Drop Window with Localized Text

You can download the sample here.

Localize when the resource file is present in different assembly or different namespace

By default, the treegrid try to read the resource file from executing assembly and its default namespace by using Assembly.GetExecuteAssembly method. When the resource file is located at different assembly or namespace, then you can let treegrid know by using GridResourceWrapper.SetResources method.

public MainWindow()
    System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-DE");
    Syncfusion.UI.Xaml.Grid.GridResourceWrapper.SetResources("Assembly_name", "namespace_name");

Edit default culture resource

You can edit default resource file by adding it to Resources folder of your application where treegrid reads the static texts from here. You can download the default resource file from here.

WPF TreeGrid with Resource File

Now, change the Name/Value pair in Resource Designer of Syncfusion.SfGrid.WPF.resx file.

Changing Default Resource File for WPF TreeGrid

WPF TreeGrid with Modified Resource File


You can refer to our WPF TreeGrid feature tour page for its groundbreaking feature representations. You can also explore our WPF TreeGrid example to know how to render and configure the treegrid.