Back to Devexpress

DataViewBase.RuntimeLocalizationStrings Property

wpf-devexpress-dot-xpf-dot-grid-dot-dataviewbase-e1d50769.md

latest4.9 KB
Original Source

DataViewBase.RuntimeLocalizationStrings Property

Gets or sets the collection of resource strings that can be localized at runtime. This is a dependency property.

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.Core.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public GridRuntimeStringCollection RuntimeLocalizationStrings { get; set; }
vb
Public Property RuntimeLocalizationStrings As GridRuntimeStringCollection

Property Value

TypeDescription
DevExpress.Xpf.Grid.GridRuntimeStringCollection

A DevExpress.Xpf.Grid.GridRuntimeStringCollection object that contains resource strings that can be localized at runtime.

|

Remarks

Individual default strings displayed within the grid (e.g. group panel text, the column chooser’s caption, etc.) can be changed at runtime. To translate individual resource strings at runtime, create a DevExpress.Xpf.Grid.RuntimeStringIdInfo object with the specified Id and Value properties, and add it to the View’s RuntimeLocalizationStrings collection. The Id property identifies the required resource string. The Value property specifies a new value for it.

Example

This example shows how to change the default string displayed in the Group Panel at runtime.

View Example: Localize Individual Strings at Runtime

xaml
<dxg:GridControl x:Name="grid" AutoGenerateColumns="AddNew">
    <dxg:GridControl.View>
        <dxg:TableView x:Name="view" AutoWidth="True"/>
    </dxg:GridControl.View>
</dxg:GridControl>
<StackPanel Grid.Row="1" Orientation="Horizontal">
    <TextBox x:Name="textBox" Width="200" KeyDown="textBox_KeyDown" Margin="3,3,3,3"/>
    <Button Content="Apply" Click="button_Click" Margin="0,3,0,3"/>
</StackPanel>
csharp
void LocalizeGroupPanelText() {
    var NewText = textBox.Text;
    var localization = new GridRuntimeStringCollection();
    localization.Add(new RuntimeStringIdInfo(GridControlRuntimeStringId.GridGroupPanelText, NewText));
    view.RuntimeLocalizationStrings = localization;
}
void button_Click(object sender, RoutedEventArgs e) {
    LocalizeGroupPanelText();
}

void textBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) {
    if (e.Key == System.Windows.Input.Key.Enter) {
        LocalizeGroupPanelText();
    }
}
vb
Private Sub LocalizeGroupPanelText()
    Dim NewText = textBox.Text
    Dim localization = New GridRuntimeStringCollection()
    localization.Add(New RuntimeStringIdInfo(GridControlRuntimeStringId.GridGroupPanelText, NewText))
    view.RuntimeLocalizationStrings = localization
End Sub

Private Sub button_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    LocalizeGroupPanelText()
End Sub

Private Sub textBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Input.KeyEventArgs)
    If e.Key = System.Windows.Input.Key.Enter Then
        LocalizeGroupPanelText()
    End If
End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the RuntimeLocalizationStrings property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

how-to-localize-individual-runtime-resource-strings-e3978/CS/WpfApplication24/MainWindow.xaml.cs#L14

csharp
localization.Add(new RuntimeStringIdInfo(GridControlRuntimeStringId.GridGroupPanelText, NewText));
    view.RuntimeLocalizationStrings = localization;
}

See Also

GridControlLocalizer

Localization

DataViewBase Class

DataViewBase Members

DevExpress.Xpf.Grid Namespace