WP7 中带有本地化支持的自定义控件 [英] Custom Control with Localization Support in WP7
本文介绍了WP7 中带有本地化支持的自定义控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经创建了 DateTimePicker 控件.现在我想为此添加本地化支持.
我已按照以下步骤操作.
<块引用>- 在 ResourceFolder 中创建了 CustomControls.de-DE.resx.
- 在该 resx 文件中添加了一些常用字符串
- 将访问修饰符更改为 Public
- 在 csproj 文件中添加了
.de-DE; - set System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-DE");在之前的 sample.cs 文件中初始化组件().
- 我的日期时间值为2 天:3 小时(s):5 分钟:32 秒(s)
仅获取英语的默认语言.
我做错了什么?请帮助我任何人.我错过了什么吗?
解决方案
在 WP7 中添加本地化支持的明确步骤
<块引用>- 创建自定义控件.
- 在属性中添加 AppResource.resx
- 在属性中添加 AppResource.es.resx 和 Appresource.it.resx 文件
- 用唯一的名字添加需要的字符串.(我们可以参考这个id的字符串使用).
- 添加它;es;在 csproj 文件中.(卸载项目,右键单击->编辑,添加支持的文化标记然后重新加载它)
- 创建示例
- 对 Sample.csproj 文件执行与第 5 步相同的操作
- 在按钮单击中更改系统的文化.(例如:Thread.CurrentThread.CurrentUICulture = newSystem.Globalization.CultureInfo("de-DE");)
- 运行项目
参考:http://www.windowsphonegeek.com/articles/Localizing-a-Windows-Phone-app-Step-by-Step
谢谢.
I have created the DateTimePicker control. Now i want to add localization Support with this.
I have followed the below steps.
- Created CustomControls.de-DE.resx inside the ResourceFolder.
- added some commonly used strings in that resx file
- changed the access modifier to Public
- added
<SupportedCulture>de-DE;</SupportedCulture>
in the csproj file.- set System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-DE"); in sample.cs file before IntializeComponent().
- my DateTimevalue was " 2 Day(s): 3 Hr (s): 5 Min(s) : 32 Sec (s)
Getting only default language that is english.
What i did wrong? Please help me anyone. Is anything i missed?
解决方案
Clear Steps To add Localization Supports in WP7
- Create Custom control.
- Add AppResource.resx inside Properties
- Add AppResource.es.resx and Appresource.it.resx files inside Properties
- Add needed strings with unique name.(we can refer the strings use of this id).
- Add it;es; in the csproj file.(unload the project, rightclick->edit, add the supportedculture tag then reload it)
- Create the Sample
- do the same as 5th step for Sample.csproj file
- Change the cultures of System in the button click.(Ex: Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-DE");)
- Run the Project
Ref: http://www.windowsphonegeek.com/articles/Localizing-a-Windows-Phone-app-Step-by-Step
Thankyou.
这篇关于WP7 中带有本地化支持的自定义控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文