PropertyEditor 本地化问题
我在 .NET 3.5 应用程序中使用 PropertyEditor 来允许用户编辑某些序列化类中包含的设置。该应用程序需要本地化才能支持多种语言。 使用标准 .NET 资源实现的本地化字符串。
PropertyEditor 需要通过属性设置类别、显示名称和描述。下面的示例:
[CategoryAttribute("Some category"),
DisplayNameAttribute("Some name"),
DescriptionAttribute("Some description"),
EditorAttribute(typeof(SomeEditor), typeof(System.Drawing.Design.UITypeEditor))]
public SomeType SomeValue {get; set;}
但是编译器不允许我在属性值中使用资源字符串,请像这样更改第一行:
[CategoryAttribute(Resources.labels.SomeCategory),
产生错误:“分配给‘App.Settings.SomeCategory’的表达式必须是常量。”
谁能帮助我如何在 WinForms 中正确本地化属性编辑器?
I am using PropertyEditor in .NET 3.5 application to allow users edit settings contained in some serialized class. This application requires localization to support multiple languages.
Localized strings implemented using standard .NET Resources.
PropertyEditor requires category, display name and description to be set via attributes. Example below:
[CategoryAttribute("Some category"),
DisplayNameAttribute("Some name"),
DescriptionAttribute("Some description"),
EditorAttribute(typeof(SomeEditor), typeof(System.Drawing.Design.UITypeEditor))]
public SomeType SomeValue {get; set;}
But compiler does not allow me to use resource string in attribute value, changing first line like this:
[CategoryAttribute(Resources.labels.SomeCategory),
Produces error: "The expression being assigned to 'App.Settings.SomeCategory' must be constant."
Can anyone help me how to properly localize property editor in WinForms?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个月前我遇到了同样的问题。我发现没有比这篇文章或其后续。
我不确定我是否喜欢这种方式,但我不知道还有什么其他选择。
I came across the same problem some month ago. I found no easier/other solution than this article or its follow-up.
I'm not sure if I like that way, but I don't know about any alternative.