• [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

  • 相关阅读:
    python实现清屏
    列表/字典/集合解析式和生成器
    SQL——pivot的用法
    前端的3大类描述
    2019-耦合性斗争笔记
    前端基础语法
    解决winform在win10下字体模糊的问题
    Xamarin.Android打包设置
    N0---我的编程教学提纲
    N0---关于变量
  • 原文地址:https://www.cnblogs.com/slow/p/2020604.html
Copyright © 2020-2023  润新知