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

  • 相关阅读:
    ASP.NET中JSON的序列化和反序列化
    Android:数据存储之SQLite
    转Android:简单联网获取网页代码
    Android:@id和@+id
    linux .run文件安装
    Mysql的Root密码忘记,查看或修改的解决方法(图文介绍)
    网页页面尺寸
    openstack
    br0
    virsh
  • 原文地址:https://www.cnblogs.com/slow/p/2020604.html
Copyright © 2020-2023  润新知