zoukankan      html  css  js  c++  java
  • [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

  • 相关阅读:
    第三课 本代码用于学习vue根组件数据的各种绑定
    第七课 键入事件,点击绑定事件,数据判断及删除事件
    第九课 代码封装localstorage
    第八课 没有封装localstorage
    第五课 vue的事件调用自定义方法
    第六课 点击事件调用自定义方法
    new多个文件编程和split单个文件多个窗口编程
    线性表特点和用法总结
    scanf在输入整型数据和字符型数据时的不同
    tasklet源码注释翻译
  • 原文地址:https://www.cnblogs.com/slow/p/2020604.html
Copyright © 2011-2022 走看看