RubyLee

博客园 首页 新随笔 联系 订阅 管理

当前版本Silverlight还不能直接支持中文显示,但我们可以通过变通的方法让其显示中文,一般可通过以下二种方案实现:

1、使用Glyphs
XAML:

1<Glyphs Fill="Red" UnicodeString="中文显示"
2  FontUri="http://localhost/ChineseFont/Fonts/649C70ED-5A7E-7277-6038-1A0DBB6BDF08.odttf"
3  FontRenderingEmSize="30" Canvas.Top="120"/>

2、使用TextBlock
XAML:
1<TextBlock TextWrapping="Wrap" x:Name="txtMsgList" Canvas.ZIndex="10"/>
JS:
 1 handleLoad: function(control, userContext, rootElement) 
 2 {
 3     this.control = control;
 4     this.rootElement=rootElement; 
 5     //下载中文字体
 6     var fontDownloader = control.CreateObject('downloader');
 7     fontDownloader.addEventListener('completed', this.createDelegate(thisthis.onFontsDownloaded));
 8     fontDownloader.open('GET', '../Silverlight/Fonts/simhei.ttf');//此处如果用.zip,则会出错,不知如何解决
 9     fontDownloader.send();
10 },
11 onFontsDownloaded: function(sender, eventArgs) {
12     var commentText = sender.findName('txtMsgList');
13     commentText.setFontSource(sender);
14     commentText.fontFamily = 'SimHei';//设置TextBlock字体为SimHei
15 },

更多中文处理,可参考:
http://www.microsoft.com/taiwan/msdn/columns/huang_jhong_cheng/Silverlight_cht_solutions.htm


posted on 2007-12-12 08:52  rubyLee  阅读(789)  评论(0)    收藏  举报