在WPF窗体应用程序中,我采用的XAML的方法实现多语言,下面是页面的代码,DataGrid的字段只认设置的默认语言,其中Label是可以实现语言切换的。请各位大虾不吝赐教,小弟在此谢过~ <ComboBox Height="23" Name="comboBox1" Width="120" SelectionChanged="comboBox1_SelectionChanged" Margin="0,0,158,238"> <ComboBoxItem Content="中文" /> <ComboBoxItem Content="英文" /> </ComboBox> <Label Content="{DynamicResource Label1}" Height="28" Name="label1" Margin="57,65,123,168" /> <DataGrid x:Name="dg_view" IsReadOnly="True" AutoGenerateColumns="False" Margin="0,180,0,0"> <DataGrid.Columns> <DataGridTextColumn Header="{DynamicResource Language_no}" Binding="{Binding LANGUAGE_NO}"/> <DataGridTextColumn Header="{DynamicResource Language_name}" Binding="{Binding LANGUAGE_NAME}"/> </DataGrid.Columns> </DataGrid>
后台代码: try { langRd = Application.LoadComponent( new Uri(@"Lang\zh-TW.xaml", UriKind.Relative)) as ResourceDictionary; } catch { }
if (langRd != null) { if (this.Resources.MergedDictionaries.Count > 0) { this.Resources.MergedDictionaries.Clear(); } this.Resources.MergedDictionaries.Add(langRd); }
添加回答
举报
0/150
提交
取消