• [Silverlight] Silverlight多语言支持


     

    首先需要当然是创建资源文件

     

     

    然后是在资源文件里对你需要支持的字符进行赋值

    添加一个cs 代码文件 添加对资源文件的读取

     

    public class

    LocalizedStrings

    {

     

    public

    LocalizedStrings()

    {

    }

     

    private static SilverlightApplication3.Resource.Resource1 resource1 = new SilverlightApplication3.Resource.Resource1

    ();

    public SilverlightApplication3.Resource.Resource1 Resource1 { get { return resource1; } }

    }

     

     
     

    添加 UserControl  用于显示 

    <TextBlock Height="28" HorizontalAlignment="Left" Name="textBlock1" Text="{Binding Path=Resource1.String1, Source={StaticResource LocalizedStrings }}" VerticalAlignment="Top" Width="141" />

    

    最后在主页面上添加 对语言切换的代码

    前台:

    <Grid x:Name="LayoutRoot" Background="White" Loaded="LayoutRoot_Loaded">

     

    <RadioButton Content="zh-CN" Height="16" HorizontalAlignment="Left" Margin="29,55,0,0" Name="radioButton1" VerticalAlignment="Top" Checked

    ="radioButton1_Checked" />

     

    <RadioButton Content="En-US" Height="16" HorizontalAlignment="Left" Margin="89,55,0,0" Name="radioButton2" VerticalAlignment="Top" Checked

    ="radioButton1_Checked" />

    <RadioButton Content="ko-KR" Height="16" Name="radioButton3" Margin="150,55,0,0" HorizontalAlignment="Left" Width="73" VerticalAlignment="Top" Checked="radioButton1_Checked" />

    <TextBlock Text="{Binding Path=Resource1.String1, Source={StaticResource LocalizedStrings }}" Margin="29,97,260,164" />

    <

    Canvas Name="content" Margin="29,142,155,50">

    <my:SilverlightControl1 HorizontalAlignment="Left" Margin="112,167,0,0" x:Name="silverlightControl11" VerticalAlignment="Top" Canvas.Left="-70" Canvas.Top="-123" Height="38" Width="125" />

    </Canvas>

    </Grid>

    

    后台:

     private void radioButton1_Checked(object sender, RoutedEventArgs e)

    {

    RadioButton rb= sender as RadioButton ;

    App.temp = rb.Content.ToString(); new SilverlightControl1 ());

    content.Children.Clear();

    content.Children.Add(

    }

    示例下载:SLTestLoc

  • 相关阅读:
    高德API+Python解决租房问题(.NET版)
    Jexus支持HTTPS协议
    pktgen使用详细教程
    结构体字节对齐2
    linux 用户空间获得纳秒级时间ns
    充分利用CPU高速缓存,提高程序效率(原理篇)
    Vue实现PC端分辨率自适应
    pip install 默认安装路径修改
    Vue AES+MD5加密 后台解密
    @Controller和@RestController的区别
  • 原文地址:https://www.cnblogs.com/slow/p/2020604.html
Copyright © 2020-2023  润新知