可以使用数据注释进行动态本地化吗?

发布于 2024-08-27 20:54:44 字数 667 浏览 6 评论 0原文

我正在尝试动态更新 Silverlight 应用程序的语言。我尝试了 Tim Heuer 提供的示例,这正是我需要的。 Silverlight 和本地化字符串数据

现在我'我正在尝试数据注释并希望有相同的行为。但没有运气...... 有人能指出我正确的方向吗?

属性的数据注释:

[Display(Name = "UserNameLabel", ResourceType = typeof(Resources.Strings.StringResources))]
[Required]
public string Username
...

我的 Xaml:

<dataInput:Label Target="{Binding ElementName=tbUserName}" PropertyPath="UserName"/> 
<TextBox x:Name="tbUserName" Text="{Binding UserName, Mode=TwoWay}" />

谢谢, 罗恩

I'm trying to dynamicly update the language of a Silverlight application. I tried the example provided by Tim Heuer and that was exactly wat I needed.
Silverlight and localizing string data

Now I'm experimenting with Data Annotations and would like to have the same behaviour.But with no luck...
Can someone point me in the right direction.

DataAnnotation of a property:

[Display(Name = "UserNameLabel", ResourceType = typeof(Resources.Strings.StringResources))]
[Required]
public string Username
...

My Xaml:

<dataInput:Label Target="{Binding ElementName=tbUserName}" PropertyPath="UserName"/> 
<TextBox x:Name="tbUserName" Text="{Binding UserName, Mode=TwoWay}" />

Thanks,
Ron

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文