为了账号安全,请及时绑定邮箱和手机立即绑定

WPF窗体应用程序中DataGrid如何实现多语言

WPF窗体应用程序中DataGrid如何实现多语言

慕的地10843 2018-12-06 22:24:33
在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);                    }
查看完整描述

4 回答

?
当年话下

TA贡献1890条经验 获得超9个赞

最好是給個有DataGrid的Demo^_^
查看完整回答
反对 回复 2019-01-21
  • 4 回答
  • 0 关注
  • 564 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信